public async Task AddOrUpdateAsync(LawyerDto dto) { var model = dto.MapTo<Content_Lawyer>(); await _contentLawyerRepository.InsertOrUpdateAsync(model); }
public async Task <IActionResult> EditLawyerAccount(LawyerDto lawyerDto, IFormFile file) { if (ModelState.IsValid) { string userId = lawyerDto.AppUserId.ToString(); var user = await _userManager.FindByIdAsync(userId); if (user == null) { ViewBag.ErrorMessage = $"User with Id = { userId } can not be found"; return(View("Not Found")); } else { user.Email = lawyerDto.Email; user.UserName = lawyerDto.UserName; var result = await _userManager.UpdateAsync(user); if (result.Succeeded) { await _lawyerService.EditLawyerAccount(lawyerDto, file); return(RedirectToAction("EditLawyer", "Lawyer", new { @id = lawyerDto.LawyerId })); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } } return(View()); }
public async Task EditLawyerAccount(LawyerDto lawyerDto, IFormFile file) { string uniqueFileName = UploadedFile(file); var lawyerAccount = await _context.Lawyers.FindAsync(lawyerDto.LawyerId); lawyerAccount.FirstName = lawyerDto.FirstName; lawyerAccount.LastName = lawyerDto.LastName; lawyerAccount.City = lawyerDto.City; lawyerAccount.Cnic = lawyerDto.Cnic; lawyerAccount.Address = lawyerDto.Address; lawyerAccount.Contact = lawyerDto.Contact; lawyerAccount.TotalExperience = lawyerDto.TotalExperience; lawyerAccount.VirtualChargesPkr = lawyerDto.VirtualChargesPkr; lawyerAccount.VirtualChargesUs = lawyerDto.VirtualChargesUs; lawyerAccount.Gender = lawyerDto.Gender; if (uniqueFileName != null) { lawyerAccount.ProfilePic = uniqueFileName; } _context.Lawyers.Update(lawyerAccount); await _context.SaveChangesAsync(); }