Пример #1
0
        public ActionResult Create(ProfilesEditViewModels model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    var profiles = new ProfilesHelper();
                    var profile = new Profile()
                    {
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        Address = model.Address,
                        UserId = User.Identity.GetUserId(),
                        DOB = model.DoB,
                        GenderId = (int)model.Gender,
                        Telephone = model.Telephone
                    };

                    profiles.Add(profile);
                    return RedirectToAction("Details");
                }
                return View(model);
            }
            catch(Exception ex)
            {
                return View();
            }
        }
Пример #2
0
        // GET: Profiles/Edit/5
        public ActionResult Edit()
        {
            var user = User.Identity.GetUser(true);
            var profile = user.Profile;
            if (profile == null)
            {
                return RedirectToAction("Create", "Profile");
            }
            ProfilesEditViewModels model = new ProfilesEditViewModels()
            {
                FirstName = profile.FirstName,
                LastName = profile.LastName,
                Address = profile.Address,
                DoB = profile.DOB,
                Gender = (GenderType)Enum.ToObject(typeof(GenderType), profile.GenderId),
                Telephone = profile.Telephone

            };
            return View(model);
        }
Пример #3
0
        public ActionResult Edit(ProfilesEditViewModels model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var profiles = new ProfilesHelper();

                    var profile = new Profile()
                    {
                        UserId = User.Identity.GetUserId(),
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        Address = model.Address,
                        DOB = model.DoB,
                        GenderId = (int)model.Gender,
                        Telephone = model.Telephone
                    };
                    profiles.Update(profile);

                    return RedirectToAction("Details");
                }
                return View(model);
            }
            catch
            {
                return View();
            }
        }