예제 #1
0
        public ActionResult Edit()
        {
            GroupsEditVM model = new GroupsEditVM();
            TryUpdateModel(model);
            GroupRepository groupRep = new GroupRepository();

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            Group group;
            if (model.ID == 0)
            {
                group = new Group();
            }
            else
            {
                group = groupRep.GetByID(model.ID);
                if (group == null)
                {
                    return RedirectToAction("List");
                }
            }

            group.Name = model.Name;

            groupRep.Save(group);

            return RedirectToAction("List");
        }
예제 #2
0
        public ActionResult Edit(int? id)
        {
            Group group;
            GroupRepository groupRep = new GroupRepository();

            if (!id.HasValue)
            {
                group = new Group();
            }
            else
            {
                group = groupRep.GetByID(id.Value);
                if (group == null)
                {
                    return RedirectToAction("List");
                }
            }

            GroupsEditVM model = new GroupsEditVM();
            model.ID = group.ID;
            model.Name = group.Name;

            return View(model);
        }