Commit c192e7b9 authored by adnansetiawan's avatar adnansetiawan
Browse files

clear some smell code

parent b0cab96d
Pipeline #24000 passed with stages
in 5 minutes and 58 seconds
......@@ -20,6 +20,9 @@ using Microsoft.IdentityModel.Tokens;
namespace EasyParking.API.Controllers
{
/// <summary>
/// booking api
/// </summary>
[ApiController]
[Route("api/booking")]
[Produces("application/json")]
......@@ -44,8 +47,9 @@ namespace EasyParking.API.Controllers
return new OkObjectResult(response);
}
/// <summary>
/// Get All Booking By Customer
/// Get All Customer
/// </summary>
/// <param name="customerid"></param>
/// <returns></returns>
/// <response code="200">Returns All Booking </response>
[HttpGet("customer/{customerid}")]
......
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net.Http;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using EasyParking.API.Dtos;
using EasyParking.API.Dtos.Request;
using EasyParking.API.Mapper;
using EasyParking.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
namespace EasyParking.API.Controllers
......
......@@ -2,20 +2,15 @@
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net.Http;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using EasyParking.API.Dtos;
using EasyParking.API.Dtos.Request;
using EasyParking.API.Mapper;
using EasyParking.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
namespace EasyParking.API.Controllers
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using EasyParking.Core;
using EasyParking.Infrastructure.Repositories;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
......
......@@ -10,7 +10,7 @@ namespace EasyParking.Core
void Delete(Guid customerId);
IReadOnlyList<Customer> GetAll();
Customer GetByEmail(string email);
Customer GetByCustomerId(Guid userId);
Customer GetByCustomerId(Guid customerId);
void SetToken(Guid customerId, string token);
void RemoveToken(Guid customerId);
}
......
......@@ -14,9 +14,9 @@ namespace EasyParking.Infrastructure.Repositories
_dbContext = dbContext;
}
public void Delete(Guid Id)
public void Delete(Guid customerId)
{
var existingCustomer = GetExistingCustomer(Id);
var existingCustomer = GetExistingCustomer(customerId);
if (existingCustomer != null)
{
_dbContext.Customers.Remove(existingCustomer);
......@@ -34,38 +34,38 @@ namespace EasyParking.Infrastructure.Repositories
var result = _dbContext.Customers.FirstOrDefault(x => x.Id == Id);
return result;
}
public Core.Customer GetByCustomerId(Guid Id)
public Core.Customer GetByCustomerId(Guid customerId)
{
var result = GetExistingCustomer(Id);
var result = GetExistingCustomer(customerId);
if (result == null)
return null;
return result.MapToEntity();
}
public void Insert(Core.Customer data)
public void Insert(Core.Customer customer)
{
_dbContext.Customers.Add(new Customer
{
Id = data.Id,
Name = data.Name,
Email = data.Email,
PhoneNumber = data.PhoneNumber,
Address = data.Address,
HashedPassword = data.HashedPassword,
CreatedDate = data.CreatedDate
Id = customer.Id,
Name = customer.Name,
Email = customer.Email,
PhoneNumber = customer.PhoneNumber,
Address = customer.Address,
HashedPassword = customer.HashedPassword,
CreatedDate = customer.CreatedDate
});
_dbContext.SaveChanges();
}
public void Update(Core.Customer data)
public void Update(Core.Customer customer)
{
var existingData = GetExistingCustomer(data.Id);
var existingData = GetExistingCustomer(customer.Id);
if (existingData != null)
{
existingData.ModifiedDate = data.ModifiedDate;
existingData.Name = data.Name;
existingData.PhoneNumber = data.PhoneNumber;
existingData.Address = data.Address;
existingData.ModifiedDate = customer.ModifiedDate;
existingData.Name = customer.Name;
existingData.PhoneNumber = customer.PhoneNumber;
existingData.Address = customer.Address;
_dbContext.Customers.Update(existingData);
_dbContext.SaveChanges();
}
......
......@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using EasyParking.Core;
using EasyParking.Infrastructure.Mapper;
using EasyParking.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
namespace EasyParking.Infrastructure.Repositories
......@@ -16,9 +15,9 @@ namespace EasyParking.Infrastructure.Repositories
_dbContext = dbContext;
}
public void Delete(Guid Id)
public void Delete(Guid userId)
{
var existingUser = GetExistingUser(Id);
var existingUser = GetExistingUser(userId);
if (existingUser != null)
{
_dbContext.Users.Remove(existingUser);
......@@ -36,36 +35,36 @@ namespace EasyParking.Infrastructure.Repositories
var result = _dbContext.Users.Include(z => z.UserRole).FirstOrDefault(x => x.Id == Id);
return result;
}
public Core.User GetByUserId(Guid Id)
public Core.User GetByUserId(Guid userId)
{
var result = GetExistingUser(Id);
var result = GetExistingUser(userId);
if (result == null)
return null;
return result.MapToEntity();
}
public void Insert(Core.User data)
public void Insert(Core.User user)
{
_dbContext.Users.Add(new User
{
Id = data.Id,
Name = data.Name,
Email = data.Email,
HashedPassword = data.HashedPassword,
CreatedDate = data.CreatedDate,
UserRoleId = data.UserRole.Id
Id = user.Id,
Name = user.Name,
Email = user.Email,
HashedPassword = user.HashedPassword,
CreatedDate = user.CreatedDate,
UserRoleId = user.UserRole.Id
});
_dbContext.SaveChanges();
}
public void Update(Core.User data)
public void Update(Core.User user)
{
var existingData = GetExistingUser(data.Id);
var existingData = GetExistingUser(user.Id);
if (existingData != null)
{
existingData.ModifiedDate = data.ModifiedDate;
existingData.Name = data.Name;
existingData.UserRoleId = data.UserRole.Id;
existingData.ModifiedDate = user.ModifiedDate;
existingData.Name = user.Name;
existingData.UserRoleId = user.UserRole.Id;
_dbContext.Users.Update(existingData);
_dbContext.SaveChanges();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment