public async Task <JsonResult> EditLawyer() { var appUser = JsonConvert.DeserializeObject <AppUser>(Request.Form["appUser"]); var lawyer = JsonConvert.DeserializeObject <Lawyer>(Request.Form["lawyer"]); var lawyerLanguage = JsonConvert.DeserializeObject <List <LawyerLanguage> >(Request.Form["lawyerLanguages"]); var lawyerQualification = JsonConvert.DeserializeObject <List <LawyerQualification> >(Request.Form["lawyerQualifications"]); //var lawyerSpecializations = JsonConvert.DeserializeObject<List<LawyerSpecialization>>(Request.Form["lawyerSpecializations"]); var lawyerExperiences = JsonConvert.DeserializeObject <List <LawyerExperience> >(Request.Form["lawyerExperiences"]); var lawyerTimings = JsonConvert.DeserializeObject <List <LawyerTiming> >(Request.Form["lawyerTimings"]); var lawyerCaseCategory = JsonConvert.DeserializeObject <List <LawyerCaseCategory> >(Request.Form["lawyerCaseCategory"]); var lawyerClient = JsonConvert.DeserializeObject <List <LawyerClient> >(Request.Form["lawyerClient"]); var lawyerLicense = JsonConvert.DeserializeObject <List <LawyerLicense> >(Request.Form["lawyerLicenses"]); var lawyerAddress = JsonConvert.DeserializeObject <List <LawyerAddress> >(Request.Form["lawyerAddress"]); // lawyer.LawyerQualifications = lawyerQualification; // lawyer.LawyerSpecializations = lawyerSpecializations; // lawyer.LawyerExperiences = lawyerExperiences; // lawyer.LawerTimings = lawyerTimings; // lawyer.LawyerCaseCategories = lawyerCaseCategory; // lawyer.LawyerClients = lawyerClient; // lawyer.lawyerLanguages = null; // lawyer.LawyerLicenses = lawyerLicense; // lawyer.LawyerAddresses = lawyerAddress; try { string userId = lawyer.AppUserId.ToString(); var user = await _userManager.FindByIdAsync(userId); //AppUser user = await _userManager.FindByNameAsync(appUser.UserName); if (user != null) { user.UserName = appUser.UserName; user.Email = appUser.Email; IdentityResult result = await _userManager.UpdateAsync(user); //IdentityResult result = await _userManager.CreateAsync(user, appUser.PasswordHash); ViewBag.Message = "User successfully edited!"; if (result.Succeeded) { //lawyer.AppUserId = user.Id; //await _userManager.AddToRoleAsync(user, "Lawyer"); string UniqueFilename = null; if (Request.Form.Files.Count > 0) { var file = Request.Form.Files[0]; string UploadFolder = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); if (!Directory.Exists(UploadFolder)) { Directory.CreateDirectory(UploadFolder); } UniqueFilename = Guid.NewGuid().ToString() + "_" + file.FileName; string filePath = Path.Combine(UploadFolder, UniqueFilename); file.CopyTo(new FileStream(filePath, FileMode.Create)); //var delpath = Path.Combine(UploadFolder, lawyer.ProfilePic); //if (System.IO.File.Exists(delpath)) //{ // System.IO.File.Delete(delpath); //} //lawyer.ProfilePic = UniqueFilename; //lawyer.OnlineStatus = "Online"; //category.Image = UniqueFilename; //await _service.AddDishCategory(category); } await _lawyerService.LawyerEdit(lawyer, lawyerQualification, lawyerLanguage, lawyerExperiences, lawyerLicense, lawyerClient, lawyerAddress, lawyerTimings, lawyerCaseCategory, UniqueFilename); return(Json("Success")); } } } catch (Exception ex) { ViewBag.Message = ex.Message; } return(Json("Success")); }