public new ActionResult Profile() { if (User == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DataAccessLayer.Profile profile = _profileService.GetByUserId(User.Identity.GetUserId()); ProfileViewModel model = new ProfileViewModel(); if (profile != null) { model = new ProfileViewModel() { Address = profile.Address, CityId = profile.CityId, CNP = profile.CNP, DateOfBirth = profile.DateOfBirth, FirstName = profile.FirstName, LastName = profile.LastName, IsUpdating = true }; } return(View(model)); }
public ActionResult UpdateProfile(ProfileViewModel model) { if (!ModelState.IsValid) { return(View("Profile", model)); } DataAccessLayer.Profile profile = _profileService.GetByUserId(User.Identity.GetUserId()); if (profile == null) { ModelState.AddModelError(string.Empty, "Invalid profile id specified"); return(View("Profile", model)); } this._profileService.Update(profile.Id, model.DateOfBirth, model.Address, model.CityId, model.FirstName, model.LastName, model.CNP, User.Identity.GetUserId()); // aici vom salva modelul cand o sa avem functie de update in repo, soon:tm: return(View("Profile", model)); }