// GET: PersonalInformation/Details/5 public IActionResult Details(int id) { var personalInformation = _personalInformationService.GetById(id); var newPersonalInformation = new NewPersonalInformation { Id = personalInformation.Id, FirstName = personalInformation.FirstName, LastName = personalInformation.LastName, EmailAddress = personalInformation.EmailAddress, ContactNumber = personalInformation.ContactNumber, AlternativeContactNumber = personalInformation.AlternativeContactNumber, Address = personalInformation.Address, MethodOfContact = personalInformation.MethodOfContact, ProfileImageUrl = personalInformation.ProfileImageUrl, JoiningDate = personalInformation.JoiningDate, BranchId = personalInformation.Branch.Id }; if (newPersonalInformation == null) { return(NotFound()); } return(View(newPersonalInformation)); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,EmailAddress,ContactNumber,AlternativeContactNumber,Address,MethodOfContact,ProfileImageUrl,JoiningDate,BranchId")] NewPersonalInformation model) { var userId = _userManager.GetUserId(User); var user = _userManager.FindByIdAsync(userId).Result; var personalInformation = BuildPersonalInformation(model, user); await _personalInformationService.Create(personalInformation); return(RedirectToAction("Index", "PersonalInformation", new { id = personalInformation.Id })); }
private PersonalInformation BuildPersonalInformation(NewPersonalInformation model, ApplicationUser user) { return(new PersonalInformation { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, EmailAddress = model.EmailAddress, ContactNumber = model.ContactNumber, AlternativeContactNumber = model.AlternativeContactNumber, Address = model.Address, MethodOfContact = model.MethodOfContact, ProfileImageUrl = "/images/personalinformation/" + model.ProfileImageUrl, JoiningDate = model.JoiningDate, Branch = _branchInformationService.GetById(model.BranchId), AppUser = user }); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,EmailAddress,ContactNumber,AlternativeContactNumber,Address,MethodOfContact,ProfileImageUrl,JoiningDate,BranchId")] NewPersonalInformation newPersonalInformation) { if (id != newPersonalInformation.Id) { return(NotFound()); } var branchToUpdate = _branchInformationService.GetById(newPersonalInformation.BranchId); var userId = _userManager.GetUserId(User); var user = _userManager.FindByIdAsync(userId).Result; if (ModelState.IsValid) { try { await _personalInformationService.UpdatePersonalInformation(newPersonalInformation.Id, newPersonalInformation.FirstName, newPersonalInformation.LastName, newPersonalInformation.EmailAddress, newPersonalInformation.ContactNumber, newPersonalInformation.AlternativeContactNumber, newPersonalInformation.Address, newPersonalInformation.MethodOfContact, newPersonalInformation.ProfileImageUrl, newPersonalInformation.JoiningDate, branchToUpdate, user); } catch (DbUpdateConcurrencyException) { if (!PersonalInformationExists(newPersonalInformation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } PopulateBranchesDropDownList(branchToUpdate.Id); return(View(newPersonalInformation)); }