Beispiel #1
0
        public ActionResult Edit(int id)
        {
            var item = Users.FetchById(id);
            if (item == null)
                return HttpNotFound();

            var model = new Models.UserCreateAndEditModel(false);
            model.User = new Models.UserModel(item);
            return View("CreateAndEdit", model);
        }
Beispiel #2
0
        public ActionResult Create([Bind(Prefix="User")] Models.UserModel value)
        {
            if (!ViewData.ModelState.IsValid)
            {
                var model = new Models.UserCreateAndEditModel(true);
                model.User = value;
                return View("CreateAndEdit", model);
            }

            // apply to BO
            value.ApplyToBO(Users.CreateNew());

            // save
            Context.SaveChanges();

            return RedirectToAction("Index");
        }
Beispiel #3
0
        public ActionResult Edit(int id, [Bind(Prefix="User")] Models.UserModel value)
        {
            var user = Users.FetchById(id);
            if(user == null)
                return HttpNotFound();

            if(!ViewData.ModelState.IsValid)
            {
                var model = new Models.UserCreateAndEditModel(false);
                model.User = value;
                return View("CreateAndEdit", model);
            }

            // apply to BO
            value.ApplyToBO(user);

            // save
            Context.SaveChanges();

            return RedirectToAction("Index");
        }
Beispiel #4
0
 public ActionResult Create()
 {
     var model = new Models.UserCreateAndEditModel(true);
     model.User = new Models.UserModel();
     return View("CreateAndEdit", model);
 }