public ActionResult Edit(EditAgentViewModel editAgentViewModel) { try { if (ModelState.IsValid) { var isUser = _iUserMaster.CheckUserIdExists(editAgentViewModel.UserId); if (isUser) { var createUserViewModel = _iUserMaster.EditUserbyUserId(editAgentViewModel.UserId); if (createUserViewModel.EmailId != editAgentViewModel.EmailId) { if (_iUserMaster.CheckEmailIdExists(editAgentViewModel.EmailId)) { ModelState.AddModelError("", "EmailId already exists"); return(View(editAgentViewModel)); } } if (createUserViewModel.MobileNo != editAgentViewModel.MobileNo) { if (_iUserMaster.CheckMobileNoExists(editAgentViewModel.MobileNo)) { ModelState.AddModelError("", "MobileNo already exists"); return(View(editAgentViewModel)); } } var result = _iUserMaster.UpdateAgentDetails(editAgentViewModel); TempData["MessageUpdateAgent"] = "Agent Details Updated Successfully"; editAgentViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory(); return(View(editAgentViewModel)); } else { editAgentViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory(); TempData["MessageCreateUsersErrors"] = "Agent Details doesn't exist"; return(View(editAgentViewModel)); } } else { editAgentViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory(); return(View("Edit", editAgentViewModel)); } } catch { throw; } }