public IActionResult UpdateProfileDetails(Lawyers_Profile model) { var _user = _db.Lawyers_Profile.Find(_userManager.GetUserId(User)); if (_user != null && model != null) { _user.Email = model.Email; _user.Experiences = model.Experiences; if (model.Certificates_Paths != null) { var images = HttpContext.Request.Form.Files; var Total = _user.Certificate_path; foreach (var image in images) { var uniqueFileName = GetUniqueFileName(image.FileName); var uploads = Path.Combine(_ihostingEnviroment.WebRootPath, "Certificates"); var Filepath = Path.Combine(uploads, uniqueFileName); image.CopyTo(new FileStream(Filepath, FileMode.Create)); Total = Total + uniqueFileName + ","; } _user.Certificate_path = Total; } var _UserController = _db.User_Profile_Controller.Find(_userManager.GetUserId(User)); _UserController.Profile_Activated = "3"; _db.SaveChanges(); } return(RedirectToAction(nameof(Index))); }
public IActionResult CreateProfile(Lawyers_Profile param) { var check = _db.Lawyers_Profile.Find(_userManager.GetUserId(User)); if (_signInManager.IsSignedIn(User)) { if (check == null) { //uploading the Certificates Paths to the database if (param.Certificates_Paths != null) { var totalfile = ""; param.Id = _userManager.GetUserId(User); var files = HttpContext.Request.Form.Files; foreach (var f in files) { var uniqueFileName = GetUniqueFileName(f.FileName); var uploads = Path.Combine(_ihostingEnviroment.WebRootPath, "Certificates"); var Filepath = Path.Combine(uploads, uniqueFileName); using (var filestream = new FileStream(Filepath, FileMode.Create)) { f.CopyTo(filestream); } //f.CopyTo(new FileStream(Filepath, FileMode.Create)); totalfile = totalfile + uniqueFileName + " ,"; } param.Certificate_path = totalfile; _db.Lawyers_Profile.Add(param); _db.SaveChanges(); //Creating the User_Profile_Controller //Search for the existing profile and update it var search = _db.User_Profile_Controller.Find(_userManager.GetUserId(User)); if (search != null) { search.Profile_Activated = "2"; //Profile Activated codes 1(Fully Activated) 2(Pending to be Activated by Admin) 0(Disactivated) search.Account_Activated = "1"; //Account_Activated codes 1(Fully Activated) 0(Disactivated) _db.SaveChanges(); } return(RedirectToAction("Index", "Lawyer")); } } else { return(RedirectToAction("Index", "Lawyer")); } } //_db.LawyerProfile.Add(param); //_db.SaveChanges(); return(View()); }