Пример #1
0
        public ActionResult Edit()
        {
            UserProfile profile = UserProfile.GetUser();

            var model = new UserProfileModel
            {
                FirstName = profile.FirstName,
                LastName = profile.LastName,
                Birthdate = profile.Birthdate.ToShortDateString(),
                Country = profile.Country,
                City = profile.City,
                Profession = profile.Profession,
                RelationshipStatus = profile.RelationshipStatus,
                LastEducationalInstitution = profile.LastEducationalInstitution
            };

            return View(model);
        }
Пример #2
0
        public ActionResult Edit(UserProfileModel model)
        {
            if (ModelState.IsValid)
            {
                UserProfile profile = UserProfile.GetUser();

                profile.FirstName = model.FirstName;
                profile.LastName = model.LastName;
                profile.Birthdate = System.Convert.ToDateTime(model.Birthdate);
                profile.Country = model.Country;
                profile.City = model.City;
                profile.Profession = model.Profession;
                profile.RelationshipStatus = model.RelationshipStatus;
                profile.LastEducationalInstitution = model.LastEducationalInstitution;

                profile.Save();

                return RedirectToAction("Index", "Profile", new { userId = UserHelper.getLoggedInUserId() });
            }

            return View(model);
        }