feat : add delivery tracking code
parent
34aabb8e13
commit
c910afcda6
|
@ -76,7 +76,8 @@ public class UserService : IUserService
|
|||
}
|
||||
}
|
||||
|
||||
return users;
|
||||
var returnUser = users.Where(r=> r.RoleName.Trim() != "مشتری" && r.FullName.Trim() != "همه کاره سیستم").ToList();
|
||||
return returnUser;
|
||||
}
|
||||
|
||||
public async Task<ApplicationUserSDto> GetUserAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
|
@ -284,9 +285,9 @@ public class UserService : IUserService
|
|||
{
|
||||
IQueryable<ApplicationRole> roles;
|
||||
if (roleName!=null)
|
||||
roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.PersianName.Trim().ToLower().Contains(roleName));
|
||||
roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.Name != "Customer" && r.PersianName.Trim().ToLower().Contains(roleName));
|
||||
else
|
||||
roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin");
|
||||
roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.Name != "Customer");
|
||||
if (page != null)
|
||||
roles = roles.Skip(page.Value * 15).Take(15);
|
||||
else
|
||||
|
@ -349,16 +350,17 @@ public class UserService : IUserService
|
|||
var roleClaims = (await _roleManager.GetClaimsAsync(applicationRole)).Where(c => c.Type == CustomClaimType.Permission).ToList();
|
||||
foreach (var roleClaim in roleClaims.ToList())
|
||||
{
|
||||
await _roleManager.RemoveClaimAsync(applicationRole,roleClaim);
|
||||
//if (request.Permissions.Contains(roleClaim.Value))
|
||||
//{
|
||||
// roleClaims.Remove(roleClaim);
|
||||
// request.Permissions.Remove(roleClaim.Value);
|
||||
//}
|
||||
var removeResult = await _roleManager.RemoveClaimAsync(applicationRole,roleClaim);
|
||||
if (!removeResult.Succeeded)
|
||||
throw new AppException(string.Join(" | ", removeResult.Errors.Select(e => e.Description)));
|
||||
}
|
||||
|
||||
foreach (var claim in request.Permissions)
|
||||
await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim));
|
||||
{
|
||||
var addResult = await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim));
|
||||
if (!addResult.Succeeded)
|
||||
throw new AppException(string.Join(" | ", addResult.Errors.Select(e => e.Description)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
public static class ApplicationPermission
|
||||
{
|
||||
public const string ManageBlogs = nameof(ManageBlogs);
|
||||
public const string ViewBlogs = nameof(ManageBlogs);
|
||||
public const string ViewBlogs = nameof(ViewBlogs);
|
||||
|
||||
public const string ManageBrands = nameof(ManageBrands);
|
||||
public const string ViewBrands = nameof(ViewBrands);
|
||||
|
@ -22,7 +22,7 @@ public static class ApplicationPermission
|
|||
public const string ManageProducts = nameof(ManageProducts);
|
||||
public const string ViewProducts = nameof(ViewProducts);
|
||||
|
||||
public const string ManageReview = nameof(AddReview);
|
||||
public const string ManageReview = nameof(ManageReview);
|
||||
public const string AddReview = nameof(AddReview);
|
||||
public const string ConfirmReview = nameof(ConfirmReview);
|
||||
public const string ViewAllReviews = nameof(ViewAllReviews);
|
||||
|
|
|
@ -95,7 +95,6 @@ public class DbInitializerService : IDbInitializerService
|
|||
{
|
||||
var seedAdmin = _adminUserSeedOptions.Value.UserSetting;
|
||||
var rootRole = await _roleManager.FindByNameAsync(seedAdmin.RoleName);
|
||||
|
||||
if (rootRole == null)
|
||||
{
|
||||
rootRole = new ApplicationRole
|
||||
|
@ -108,9 +107,17 @@ public class DbInitializerService : IDbInitializerService
|
|||
foreach (var claim in ApplicationClaims.AllClaims)
|
||||
await _roleManager.AddClaimAsync(rootRole, claim);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var claim in ApplicationClaims.AllClaims)
|
||||
{
|
||||
var claims = await _roleManager.GetClaimsAsync(rootRole);
|
||||
if (claims.FirstOrDefault(c => c.Value == claim.Value) == null)
|
||||
await _roleManager.AddClaimAsync(rootRole, claim);
|
||||
}
|
||||
}
|
||||
|
||||
var managerRole = await _roleManager.FindByNameAsync("Manager");
|
||||
|
||||
if (managerRole == null)
|
||||
{
|
||||
managerRole = new ApplicationRole
|
||||
|
@ -124,6 +131,15 @@ public class DbInitializerService : IDbInitializerService
|
|||
foreach (var claim in ApplicationClaims.AllClaims)
|
||||
await _roleManager.AddClaimAsync(managerRole, claim);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var claim in ApplicationClaims.AllClaims)
|
||||
{
|
||||
var claims = await _roleManager.GetClaimsAsync(managerRole);
|
||||
if (claims.FirstOrDefault(c => c.Value == claim.Value) == null)
|
||||
await _roleManager.AddClaimAsync(managerRole, claim);
|
||||
}
|
||||
}
|
||||
|
||||
var customerRole = await _roleManager.FindByNameAsync("Customer");
|
||||
if (customerRole == null)
|
||||
|
@ -139,5 +155,14 @@ public class DbInitializerService : IDbInitializerService
|
|||
foreach (var claim in ApplicationClaims.CustomerClaims)
|
||||
await _roleManager.AddClaimAsync(customerRole, claim);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var claim in ApplicationClaims.CustomerClaims)
|
||||
{
|
||||
var claims = await _roleManager.GetClaimsAsync(customerRole);
|
||||
if (claims.FirstOrDefault(c => c.Value == claim.Value) == null)
|
||||
await _roleManager.AddClaimAsync(customerRole, claim);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue