예제 #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
        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();
            }
        }