Exemplo n.º 1
0
        public ActionResult Create(Role role)
        {
            try
            {
                if (!ModelState.IsValid)
                    throw new Exception();

                this.UnitOfWork.RoleRepository.Insert(role);
                this.UnitOfWork.Save();

                return RedirectToAction("Index", "Role");
            }
            catch
            {
                return View(role);
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(Role role)
        {
            try
            {
                if (!ModelState.IsValid)
                    return View(role);

                var originalRole = this.UnitOfWork.RoleRepository.GetByID(role.Id);

                if (originalRole == null)
                    throw new Exception();

                originalRole.Name = role.Name;
                originalRole.Description = role.Description;
                originalRole.ModifiedDate = DateTime.Now;

                this.UnitOfWork.RoleRepository.Update(originalRole);
                this.UnitOfWork.Save();

                return RedirectToAction("Index", "Role");
            }
            catch
            {
                return View(role);
            }
        }
Exemplo n.º 3
0
 // CREATE ROLE
 public ActionResult Create()
 {
     var model = new Role();
     return View(model);
 }