public async Task <IActionResult> Create([Bind("UserId,Id,UserFullName,UserDateOfBirth,UserNID,IsBpdbEmployee,BpdbEmployeeId,UserProfession,UserDesignation,UserAddress,UserAlternateEmail,UserAlternateMobile,UserSecurityQuestionId,SecurityQuestionAnswer,IsProfileSubmitted,SignatureFileName,BpdbDivisionId,BpdbEmpDesignation,ZoneCode,CircleCode,SnDCode,SubstationId")] TblUserProfileDetail tblUserProfileDetail) { //de4605d2 - b29c - 4d83 - 9cc6 - 501063993724 var id = tblUserProfileDetail.Id; var user = await _userManager.FindByIdAsync(id); //var user = _userManager.Users.Where(i => i.Id == id).SingleOrDefault(); //TblUserRegistrationDetail user = userManager.Users.Where(i=> i.Id == id); if (user == null) { ViewBag.ErrorMessage = $"User with Id = {id} cannot be found"; return(View("NotFound")); } else { user.UserActivationStatusId = 2; //user.City = model.City; var result = await _userManager.UpdateAsync(user); } if (ModelState.IsValid) { _contextPDB.Add(tblUserProfileDetail); await _contextPDB.SaveChangesAsync(); return(RedirectToAction("ProfileDetials", new { id = tblUserProfileDetail.Id })); //return RedirectToAction(nameof(Index)); } ViewData["BpdbEmployeeId"] = new SelectList(_contextPDB.UserBpdbEmployee, "BpdbEmployeeId", "BpdbEmployeeId", tblUserProfileDetail.BpdbEmployeeId); ViewData["Id"] = new SelectList(_contextPDB.TblUserRegistrationDetail, "Id", "Id", tblUserProfileDetail.Id); ViewData["UserSecurityQuestionId"] = new SelectList(_contextPDB.UserSecurityQuestion, "UserSecurityQuestionId", "UserSecurityQuestion", tblUserProfileDetail.UserSecurityQuestionId); ViewData["BpdbDivisionId"] = new SelectList(_contextPDB.UserBpdbDivision, "BpdbDivisionId", "BpdbDivisionName"); ViewData["ZoneCode"] = new SelectList(_contextPDB.LookUpZoneInfo.OrderBy(d => d.ZoneCode), "ZoneCode", "ZoneName"); return(View(tblUserProfileDetail)); }
public async Task <IActionResult> Edit(int UserId, [Bind("UserId,Id,UserFullName,UserDateOfBirth,UserNID,IsBpdbEmployee,BpdbEmployeeId,UserProfession,UserDesignation,UserAddress,UserAlternateEmail,UserAlternateMobile,UserSecurityQuestionId,SecurityQuestionAnswer,IsProfileSubmitted,SignatureFileName,BpdbDivisionId,BpdbEmpDesignation,ZoneCode,CircleCode,SnDCode,SubstationId")] TblUserProfileDetail tblUserProfileDetail) { // if (UserId != tblUserProfileDetail.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _contextPDB.Update(tblUserProfileDetail); await _contextPDB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblUserProfileDetailExists(tblUserProfileDetail.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("ProfileDetials", new { id = tblUserProfileDetail.Id })); //return RedirectToAction(nameof(Index)); } ViewData["BpdbEmployeeId"] = new SelectList(_contextPDB.UserBpdbEmployee, "BpdbEmployeeId", "BpdbEmployeeId", tblUserProfileDetail.BpdbEmployeeId); ViewData["Id"] = new SelectList(_contextPDB.TblUserRegistrationDetail, "Id", "Id", tblUserProfileDetail.Id); ViewData["UserSecurityQuestionId"] = new SelectList(_contextPDB.UserSecurityQuestion, "UserSecurityQuestionId", "UserSecurityQuestion", tblUserProfileDetail.UserSecurityQuestionId); ViewData["BpdbDivisionId"] = new SelectList(_contextPDB.UserBpdbDivision, "BpdbDivisionId", "BpdbDivisionName"); ViewData["ZoneCode"] = new SelectList(_contextPDB.LookUpZoneInfo.OrderBy(d => d.ZoneCode), "ZoneCode", "ZoneName"); //return RedirectToAction("ProfileDetials") return(View(tblUserProfileDetail)); }