Пример #1
0
        // GET: Roles/Details/5
        public ActionResult Details(string id)
        {
            
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Roles roles = db.IdentityRoles.Find(id);
            if (roles == null)
            {
                return HttpNotFound();
            }
            ListRoleViewModel model = new ListRoleViewModel
            {
                Id = roles.Id,
                Name = roles.Name
            };

            return View(model);
        }
Пример #2
0
        // GET: Roles
        public ActionResult Index(RolesMessageId? message)
        {
            ViewBag.StatusMessage =
                message == RolesMessageId.CreateRoleFail ? "No se pudo crear el rol, ya existe." :
                message == RolesMessageId.EditRoleFail ? "No se pudo editar el rol, ya existe." :
                "";

            List<ListRoleViewModel> model = new List<ListRoleViewModel>();

            foreach(var item in db.IdentityRoles.ToList().OrderBy(item => item.Name))
            {
                ListRoleViewModel role = new ListRoleViewModel
                {
                    Id = item.Id,
                    Name = item.Name
                };
                model.Add(role);
            }

            return View(model.ToList());
        }