diff --git a/src/comissions.app.api/Controllers/SellerProfileController.cs b/src/comissions.app.api/Controllers/SellerProfileController.cs index d941d9c..bbf3d72 100644 --- a/src/comissions.app.api/Controllers/SellerProfileController.cs +++ b/src/comissions.app.api/Controllers/SellerProfileController.cs @@ -61,6 +61,10 @@ public class SellerProfileController : Controller return BadRequest(); return Unauthorized(); } + + if (_dbContext.UserSellerProfiles.Any(x => x.Name.ToLower() == model.Name.ToLower())) + return BadRequest(); + var updatedSellerProfile = model.ToModel(existingSellerProfile); updatedSellerProfile = _dbContext.UserSellerProfiles.Update(updatedSellerProfile).Entity; await _dbContext.SaveChangesAsync(); @@ -100,7 +104,8 @@ public class SellerProfileController : Controller public async Task UpdateSellerProfilePage([FromBody]SellerProfilePageSettingsModel model) { var userId = User.GetUserId(); - var existingSellerProfile = await _dbContext.UserSellerProfiles.Include(x=>x.SellerProfilePageSettings).FirstOrDefaultAsync(sellerProfile=>sellerProfile.UserId==userId); + var existingSellerProfile = await _dbContext.UserSellerProfiles + .Include(x=>x.SellerProfilePageSettings).FirstOrDefaultAsync(sellerProfile=>sellerProfile.UserId==userId); if (existingSellerProfile == null) { var sellerProfileRequest = await _dbContext.SellerProfileRequests.FirstOrDefaultAsync(request=>request.UserId==userId && request.Accepted==false);