public int UpdateComment(UserViewModel userviewModel) { LYSApp.Data.DBEntity.PGReview pgReview = new LYSApp.Data.DBEntity.PGReview(); pgReview.UserID = userviewModel.UserID; pgReview.Comments = userviewModel.HouseReviewModel.Comments; pgReview.CommentTime = DateTime.Now; pgReview.Rating = userviewModel.HouseReviewModel.Rating; /**------commenting code due to DBUpdate**/ pgReview.PGDetailID = (from pg in pgDetailRepository.Get() join a in apartmentRepository.Get() on pg.PGDetailID equals a.PGDetailID join x in blockRepository.Get() on a.ApartmentID equals x.ApartmentID join h in houseRepository.Get() on x.BlockID equals h.BlockID join r in roomRepository.Get() on h.HouseID equals r.HouseID join b in bedRepository.Get() on r.RoomID equals b.RoomID join u in userRepository.Get() on b.UserID equals u.UserID select pg.PGDetailID).FirstOrDefault(); pgReviewRepository.Insert(pgReview); return unitOfWork.SaveChanges(); }
public int UpdateUser(UserViewModel userViewModel) { //getting the lates data from DB var dbUser = userRepository.FirstOrDefault(m => m.UserID == userViewModel.UserID); if (dbUser != null){ dbUser.UserName = userViewModel.UserName; dbUser.PhoneNumber = userViewModel.PhoneNumber; dbUser.FirstName = userViewModel.FirstName; dbUser.LastName = userViewModel.LastName; dbUser.Gender = userViewModel.Gender; dbUser.ProfilePicture = String.Empty; dbUser.Email = userViewModel.Email; if(dbUser.UserDetails != null && dbUser.UserDetails.Count > 0){ dbUser.UserDetails.FirstOrDefault().PresentAddress = userViewModel.PresentAddress; dbUser.UserDetails.FirstOrDefault().PermanentAddress = userViewModel.PermanentAddress; dbUser.UserDetails.FirstOrDefault().GovtIDType = userViewModel.GovtIDType; dbUser.UserDetails.FirstOrDefault().GovtID = userViewModel.GovtID; dbUser.UserDetails.FirstOrDefault().UserProfession = userViewModel.UserProfession; dbUser.UserDetails.FirstOrDefault().OfficeLocation = userViewModel.OfficeLocation; dbUser.UserDetails.FirstOrDefault().CurrentEmployer = userViewModel.CurrentEmployer; dbUser.UserDetails.FirstOrDefault().EmployeeID = userViewModel.EmployeeID; dbUser.UserDetails.FirstOrDefault().HighestEducation = userViewModel.HighestEducation; dbUser.UserDetails.FirstOrDefault().InstitutionName = userViewModel.InstitutionName; dbUser.UserDetails.FirstOrDefault().LastUpdatedOn = DateTime.Now; } else { LYSApp.Data.DBEntity.UserDetail userDetail = new LYSApp.Data.DBEntity.UserDetail(); userDetail.PresentAddress = userViewModel.PresentAddress; userDetail.PermanentAddress = userViewModel.PermanentAddress; userDetail.GovtIDType = userViewModel.GovtIDType; userDetail.GovtID = userViewModel.GovtID; userDetail.UserProfession = userViewModel.UserProfession; userDetail.OfficeLocation = userViewModel.OfficeLocation; userDetail.CurrentEmployer = userViewModel.CurrentEmployer; userDetail.EmployeeID = userViewModel.EmployeeID; userDetail.HighestEducation = userViewModel.HighestEducation; userDetail.InstitutionName = userViewModel.InstitutionName; userDetail.CreatedOn = DateTime.Now; dbUser.UserDetails = new List<LYSApp.Data.DBEntity.UserDetail>(); dbUser.UserDetails.Add(userDetail); userDetailsRepository.Insert(userDetail); } } userRepository.Update(dbUser); return unitOfWork.SaveChanges(); }
public ActionResult ViewProfile(UserViewModel userViewModel) { userViewModel.Status = 1; userViewModel.LastUpdatedOn = DateTime.Now; if (userViewModel.UserID == 0) { //UserController accountController = new UserController((UserManagement)userManagement); //accountController.Logout(); } int count = userManagement.UpdateUser(userViewModel); if (count > 0) { var user = SessionManager.GetSessionUser(); user.ProfilePicture = userViewModel.ProfilePicture; TempData["message"] = "Profile updated successfully!"; } else { TempData["message"] = "Error in updating your profile.Please try again later"; } return PartialView("_EditProfile", userViewModel); }
public ActionResult AddComment(UserViewModel userViewModel) { userManagement.UpdateComment(userViewModel); return PartialView("_ReviewComments", userViewModel); }
public async Task<ActionResult> ChangePassword(UserViewModel userViewModel) { bool hasPassword = HasPassword(); ViewBag.HasLocalPassword = hasPassword; ViewBag.StatusMessage = "An error has occurred."; if (hasPassword) { if (ModelState.IsValid) { var result = await UserManager.ChangePasswordAsync(long.Parse(User.Identity.GetUserId()), userViewModel.ManageUserViewModel.OldPassword, userViewModel.ManageUserViewModel.NewPassword); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(long.Parse(User.Identity.GetUserId())); await SignInAsync(user, isPersistent: false); ViewBag.StatusMessage = "Your password has been changed."; } } } return PartialView("_Verification", userViewModel); }