Skip to content

Commit 7909c46

Browse files
authored
Merge pull request #319 from dotnetgoo/dev
Code cleaned
2 parents 94976c7 + f40537e commit 7909c46

File tree

158 files changed

+539
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+539
-761
lines changed

FleetFlow.DAL/AppSettings.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace FleetFlow.DAL
8+
{
9+
public class AppSettings
10+
{
11+
public const string CONNECTION_STRING = "Server=localhost; User Id=postgres; Password=root; Database=eCommerce;";
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using FleetFlow.Api.Models;
22
using FleetFlow.Service.Exceptions;
33
using FleetFlow.Service.Interfaces.Authorizations;
4-
using FleetFlow.Shared.Helpers;
54
using Microsoft.AspNetCore.Mvc;
65
using Microsoft.AspNetCore.Mvc.Controllers;
76
using Microsoft.AspNetCore.Mvc.Filters;
@@ -15,37 +14,37 @@ public CustomAuthorizeAttribute() : base(typeof(CustomAuthorizationFilter))
1514
{
1615
}
1716

18-
public class CustomAuthorizationFilter : IAuthorizationFilter
17+
public class CustomAuthorizationFilter : IAuthorizationFilter
1918
{
20-
private readonly IRolePermissionService rolePermissionService;
19+
private readonly IRolePermissionService rolePermissionService;
2120

2221
public CustomAuthorizationFilter(IRolePermissionService rolePermissionService)
2322
{
2423
this.rolePermissionService = rolePermissionService;
2524
}
2625

27-
public void OnAuthorization(AuthorizationFilterContext context)
26+
public void OnAuthorization(AuthorizationFilterContext context)
2827
{
2928

3029
var controllerDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
31-
var result = controllerDescriptor?.ControllerName.ToLower() + "." + controllerDescriptor?.ActionName.ToLower();
32-
var role = context.HttpContext?.User?.Claims?.FirstOrDefault(u => u.Type == ClaimTypes.Role)?.Value ?? string.Empty;
33-
var res = this.rolePermissionService.CheckPermission(role, result).GetAwaiter().GetResult();
30+
var result = controllerDescriptor?.ControllerName.ToLower() + "." + controllerDescriptor?.ActionName.ToLower();
31+
var role = context.HttpContext?.User?.Claims?.FirstOrDefault(u => u.Type == ClaimTypes.Role)?.Value ?? string.Empty;
32+
var res = this.rolePermissionService.CheckPermission(role, result).GetAwaiter().GetResult();
3433

3534
if (!res)
35+
{
36+
var exception = new FleetFlowException(403, "You do not have permission for this method");
37+
context.Result = new ObjectResult(new Response
3638
{
37-
var exception = new FleetFlowException(403, "You do not have permission for this method");
38-
context.Result = new ObjectResult(new Response
39-
{
40-
Code = exception.Code,
41-
Message = exception.Message
42-
})
43-
{
44-
StatusCode = exception.Code
45-
};
46-
}
39+
Code = exception.Code,
40+
Message = exception.Message
41+
})
42+
{
43+
StatusCode = exception.Code
44+
};
45+
}
4746
}
4847

4948
}
50-
49+
5150
}

src/FleetFlow.Api/Controllers/AdressesController.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using FleetFlow.Domain.Congirations;
33
using FleetFlow.Service.DTOs.Address;
44
using FleetFlow.Service.Interfaces.Addresses;
5-
using FleetFlow.Service.Interfaces.Orders;
65
using Microsoft.AspNetCore.Mvc;
76

87
namespace FleetFlow.Api.Controllers;
@@ -67,9 +66,9 @@ public async ValueTask<IActionResult> GetAllAsync([FromQuery] PaginationParams @
6766
[HttpPut("{id}")]
6867
public async ValueTask<IActionResult> PutAsync(long id, AddressForCreationDto dto)
6968
=> Ok(new Response
70-
{
71-
Code = 200,
72-
Message = "OK",
73-
Data = await this.addressService.UpdateByIdAsync(id, dto)
69+
{
70+
Code = 200,
71+
Message = "OK",
72+
Data = await this.addressService.UpdateByIdAsync(id, dto)
7473
});
7574
}

src/FleetFlow.Api/Controllers/AnswerController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public async ValueTask<IActionResult> GetAllByUserIdAsync([FromQuery] Pagination
107107
/// <param name="dto"></param>
108108
/// <returns></returns>
109109
[HttpPut("{id:long}")]
110-
public async ValueTask<IActionResult> UpdateAnswerAsync([FromRoute]long id, [FromBody]string message)
110+
public async ValueTask<IActionResult> UpdateAnswerAsync([FromRoute] long id, [FromBody] string message)
111111
=> Ok(new Response
112112
{
113113
Code = 200,

src/FleetFlow.Api/Controllers/AuthController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public async Task<IActionResult> AuthenticateAsync(LoginDto dto)
2424
Data = await this.authService.AuthenticateAsync(dto.Email, dto.Password)
2525
});
2626
}
27-
27+
2828
}
2929
}

src/FleetFlow.Api/Controllers/BonusSettingsController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public async ValueTask<IActionResult> DeleteAsync(long id) =>
4646

4747

4848
[HttpGet]
49-
public async ValueTask<IActionResult> GetAllAsync([FromQuery]PaginationParams @params) =>
49+
public async ValueTask<IActionResult> GetAllAsync([FromQuery] PaginationParams @params) =>
5050
Ok(new Response()
5151
{
5252
Code = 200,

src/FleetFlow.Api/Controllers/CartsController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using FleetFlow.Domain.Congirations;
33
using FleetFlow.Service.DTOs.Carts;
44
using FleetFlow.Service.Interfaces.Orders;
5-
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
76

87
namespace FleetFlow.Api.Controllers

src/FleetFlow.Api/Controllers/CheckoutController.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using FleetFlow.Api.Models;
2-
using Microsoft.AspNetCore.Mvc;
3-
using FleetFlow.Api.Extensions;
4-
using FleetFlow.Service.DTOs.Orders;
1+
using FleetFlow.Api.Extensions;
2+
using FleetFlow.Api.Models;
53
using FleetFlow.Service.DTOs.Address;
6-
using FleetFlow.Service.DTOs.Payments;
74
using FleetFlow.Service.DTOs.Attachments;
8-
using FleetFlow.Service.Interfaces.Orders;
95
using FleetFlow.Service.DTOs.Discounts;
6+
using FleetFlow.Service.DTOs.Orders;
7+
using FleetFlow.Service.DTOs.Payments;
8+
using FleetFlow.Service.Interfaces.Orders;
9+
using Microsoft.AspNetCore.Mvc;
1010

1111
namespace FleetFlow.Api.Controllers;
1212

src/FleetFlow.Api/Controllers/DiscountsController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using FleetFlow.Domain.Enums;
44
using FleetFlow.Service.DTOs.Discounts;
55
using FleetFlow.Service.Interfaces.Products;
6-
using FleetFlow.Service.Services.Products;
76
using Microsoft.AspNetCore.Mvc;
87

98
namespace FleetFlow.Api.Controllers

src/FleetFlow.Api/Controllers/InventoriesController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using FleetFlow.Domain.Entities.Warehouses;
44
using FleetFlow.Service.DTOs.Inventories;
55
using FleetFlow.Service.Interfaces.Warehouses;
6-
using FleetFlow.Service.Services.Products;
76
using Microsoft.AspNetCore.Mvc;
87

98
namespace FleetFlow.Api.Controllers

src/FleetFlow.Api/Controllers/InventoryLogController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public InventoryLogController(IInventoryLogService inventoryLogService)
1616
_inventoryLogService = inventoryLogService;
1717
}
1818
[HttpPost]
19-
public async ValueTask<ActionResult<InventoryLogForResultDto>> PostAsync(InventoryLogForCreationDto dto)
19+
public async ValueTask<ActionResult<InventoryLogForResultDto>> PostAsync(InventoryLogForCreationDto dto)
2020
=> Ok(new Response
2121
{
2222
Code = 200,

src/FleetFlow.Api/Controllers/LocationsController.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public LocationsController(ILocationService locationService)
1919
/// </summary>
2020
/// <returns></returns>
2121
[HttpGet]
22-
public async ValueTask<IActionResult> GetAllAsync([FromQuery]PaginationParams @params)
23-
=>Ok(new Response
22+
public async ValueTask<IActionResult> GetAllAsync([FromQuery] PaginationParams @params)
23+
=> Ok(new Response
2424
{
2525
Code = 200,
2626
Message = "OK",
@@ -48,7 +48,7 @@ public async ValueTask<IActionResult> GetAsync(long id)
4848
/// <param name="dto"></param>
4949
/// <returns></returns>
5050
[HttpPost]
51-
public async ValueTask<IActionResult> PostAsync([FromBody]LocationForCreationDto dto)
51+
public async ValueTask<IActionResult> PostAsync([FromBody] LocationForCreationDto dto)
5252
=> Ok(new Response
5353
{
5454
Code = 200,

src/FleetFlow.Api/Controllers/OrderActionsController.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using FleetFlow.Api.Models;
2-
using Microsoft.AspNetCore.Mvc;
32
using FleetFlow.Service.Interfaces.Orders;
3+
using Microsoft.AspNetCore.Mvc;
44

55
namespace FleetFlow.Api.Controllers;
66

@@ -20,7 +20,7 @@ public async Task<IActionResult> StartPendingAsync(long orderId)
2020
Message = "OK",
2121
Data = await orderActionService.StartPendingAsync(orderId)
2222
});
23-
23+
2424

2525
[HttpPost("preparing")]
2626
public async Task<IActionResult> StartPreparingAsync(long orderId)

src/FleetFlow.Api/Controllers/OrdersController.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using FleetFlow.Api.Models;
2+
using FleetFlow.Domain.Congirations;
23
using FleetFlow.Domain.Enums;
3-
using Microsoft.AspNetCore.Mvc;
44
using FleetFlow.Service.DTOs.Orders;
5-
using FleetFlow.Domain.Congirations;
65
using FleetFlow.Service.Interfaces.Orders;
6+
using Microsoft.AspNetCore.Mvc;
77

88
namespace FleetFlow.Api.Controllers;
99

src/FleetFlow.Api/Controllers/PaymentsController.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using FleetFlow.Api.Models;
2-
using FleetFlow.Api.Extensions;
3-
using Microsoft.AspNetCore.Mvc;
1+
using FleetFlow.Api.Extensions;
2+
using FleetFlow.Api.Models;
43
using FleetFlow.Domain.Congirations;
5-
using FleetFlow.Service.DTOs.Payments;
64
using FleetFlow.Service.DTOs.Attachments;
5+
using FleetFlow.Service.DTOs.Payments;
76
using FleetFlow.Service.Interfaces.Orders;
7+
using Microsoft.AspNetCore.Mvc;
88

99
namespace FleetFlow.Api.Controllers;
1010

src/FleetFlow.Api/Controllers/PermissionsController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task<IActionResult> GetAsync(long id)
5353
});
5454

5555
[HttpGet]
56-
public async Task<IActionResult> GetAllAsync([FromQuery] PaginationParams @params)
56+
public async Task<IActionResult> GetAllAsync([FromQuery] PaginationParams @params)
5757
=> Ok(new Response
5858
{
5959
Code = 200,

src/FleetFlow.Api/Controllers/ProductCategoriesController.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using FleetFlow.Api.Models;
2-
using Microsoft.AspNetCore.Mvc;
2+
using FleetFlow.Domain.Congirations;
33
using FleetFlow.Service.DTOs.Products;
44
using FleetFlow.Service.Interfaces.Products;
5-
using FleetFlow.Domain.Congirations;
5+
using Microsoft.AspNetCore.Mvc;
66

77
namespace FleetFlow.Api.Controllers
88
{
@@ -24,7 +24,7 @@ public async ValueTask<IActionResult> PostAsync(ProductCategoryCreationDto dto)
2424
});
2525

2626
[HttpPut("product-category")]
27-
public async ValueTask<IActionResult> PutAsync([FromQuery]long id, ProductCategoryUpdateDto dto)
27+
public async ValueTask<IActionResult> PutAsync([FromQuery] long id, ProductCategoryUpdateDto dto)
2828
=> Ok(new Response
2929
{
3030
Code = 200,
@@ -33,7 +33,7 @@ public async ValueTask<IActionResult> PutAsync([FromQuery]long id, ProductCatego
3333
});
3434

3535
[HttpDelete("product-category")]
36-
public async ValueTask<IActionResult> DeleteAsync([FromQuery]long id)
36+
public async ValueTask<IActionResult> DeleteAsync([FromQuery] long id)
3737
=> Ok(new Response
3838
{
3939
Code = 200,

src/FleetFlow.Api/Controllers/ProductsController.cs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using FleetFlow.Domain.Entities.Products;
44
using FleetFlow.Service.DTOs.Product;
55
using FleetFlow.Service.Interfaces.Products;
6-
using FleetFlow.Service.Services;
7-
using Microsoft.AspNetCore.Authorization;
86
using Microsoft.AspNetCore.Mvc;
97

108
namespace FleetFlow.Api.Controllers

src/FleetFlow.Api/Controllers/QuestionsController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public async ValueTask<IActionResult> GetAllAsync([FromQuery] PaginationParams @
7777
/// <param name="dto"></param>
7878
/// <returns></returns>
7979
[HttpPut("id")]
80-
public async ValueTask<IActionResult> PutAsync(long id, [FromBody]string message)
80+
public async ValueTask<IActionResult> PutAsync(long id, [FromBody] string message)
8181
=> Ok(new Response
8282
{
8383
Code = 200,

src/FleetFlow.Api/Controllers/RolesController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using FleetFlow.Api.Models;
22
using FleetFlow.Domain.Congirations;
3-
using FleetFlow.Domain.Entities.Authorizations;
43
using FleetFlow.Service.DTOs.Roles;
54
using FleetFlow.Service.Interfaces.Authorizations;
65
using Microsoft.AspNetCore.Mvc;

src/FleetFlow.Api/Controllers/StaffsController.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace FleetFlow.Api.Controllers
88
{
99
public class StaffsController : RestfulSense
1010
{
11-
private IStaffService staffService;
11+
private IStaffService staffService;
1212

1313
public StaffsController(IStaffService staffService)
1414
{
@@ -22,7 +22,7 @@ public StaffsController(IStaffService staffService)
2222
/// <param name="dto"></param>
2323
/// <returns></returns>
2424
[HttpPost]
25-
public async ValueTask<IActionResult> CreateAsync([FromBody]StaffForCreationDto dto)
25+
public async ValueTask<IActionResult> CreateAsync([FromBody] StaffForCreationDto dto)
2626
=> Ok(new Response
2727
{
2828
Code = 200,
@@ -36,7 +36,7 @@ public async ValueTask<IActionResult> CreateAsync([FromBody]StaffForCreationDto
3636
/// <param name="dto"></param>
3737
/// <returns></returns>
3838
[HttpPut]
39-
public async ValueTask<IActionResult> UpdateAsync(long id,[FromBody] StaffForUpdateDto dto)
39+
public async ValueTask<IActionResult> UpdateAsync(long id, [FromBody] StaffForUpdateDto dto)
4040
=> Ok(new Response
4141
{
4242
Code = 200,
@@ -76,7 +76,7 @@ public async ValueTask<IActionResult> GetByIdAsync(long id)
7676
/// <param name="params"></param>
7777
/// <returns></returns>
7878
[HttpGet]
79-
public async ValueTask<IActionResult> GetAllAsync([FromQuery]PaginationParams @params)
79+
public async ValueTask<IActionResult> GetAllAsync([FromQuery] PaginationParams @params)
8080
=> Ok(new Response
8181
{
8282
Code = 200,
@@ -110,6 +110,6 @@ public async ValueTask<IActionResult> GetByUserId(long userId)
110110
Message = "Ok",
111111
Data = await staffService.RetrieveByUserIdAsync(userId)
112112
});
113-
113+
114114
}
115115
}

src/FleetFlow.Api/Controllers/UsersController.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
using FleetFlow.Api.Attributes;
12
using FleetFlow.Api.Models;
2-
using Microsoft.AspNetCore.Mvc;
3-
using FleetFlow.Service.DTOs.User;
43
using FleetFlow.Domain.Congirations;
4+
using FleetFlow.Service.DTOs.User;
55
using FleetFlow.Service.Interfaces.Users;
6-
using FleetFlow.Api.Attributes;
6+
using Microsoft.AspNetCore.Mvc;
77

88
namespace FleetFlow.Api.Controllers;
99

src/FleetFlow.Api/Extensions/HttpContextExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static void InitAccessor(this WebApplication app)
88
{
99
using var scope = app.Services.CreateScope();
1010

11-
HttpContextHelper.Accessor = scope.ServiceProvider.GetRequiredService<IHttpContextAccessor>();
11+
HttpContextHelper.Accessor = scope.ServiceProvider.GetRequiredService<IHttpContextAccessor>();
1212
}
1313
}
1414
}

0 commit comments

Comments
 (0)