Example #1
0
        public ActionResult ProfileNew()
        {
            ProfileNewProfileViewResult result = new ProfileNewProfileViewResult();
            result.Profile = new Profile { UserId = user.Id };

            result.ProfileSex = ProfileSexRepository.ProfileSex;
            return View(result);
        }
Example #2
0
        public ActionResult ProfileNew(ProfileNewProfileViewResult newProfile)
        {
            if (ModelState.IsValid)
            {
                Profile result = ProfileRepository.GetProfile(newProfile.Profile.ProfileId);
                if (result == null)
                {
                    newProfile.Profile.ProfileActivityId = 1;
                    ProfileRepository.NewProfile(newProfile.Profile);
                    user.ProfileId = newProfile.Profile.ProfileId;
                    UserManager.UpdateAsync(user);
                    TempData["toastrMessage"] = String.Format("Профиль для {0} создан", user.UserName);
                    TempData["toastrType"] = "success";
                    return RedirectToAction("Index");
                }
                else
                {
                    ModelState.AddModelError("Профиль","Уже создан");
                }
            }

            newProfile.ProfileSex = ProfileSexRepository.ProfileSex;
            return View(newProfile);
        }