コード例 #1
0
        public ActionResult Details(string id)
        {
            Papel papel = InternoRoleManager.FindById(id);

            string[] memberIDs            = papel.Users.Select(x => x.UserId).ToArray();
            IEnumerable <Usuario> membros = InternoUserManager.Users.Where(x => memberIDs.Any(y => y == x.Id));

            return(View(new PapelDetailsModel {
                Role = papel, Membros = membros
            }));
        }
コード例 #2
0
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Papel papel = InternoRoleManager.FindById(id);

            if (papel == null)
            {
                return(HttpNotFound());
            }

            return(View(papel));
        }
コード例 #3
0
        public ActionResult Edit(PapelViewModel pvm)
        {
            if (ModelState.IsValid)
            {
                Papel papel = InternoRoleManager.FindById(pvm.Id);
                papel.Name = pvm.Nome;

                IdentityResult resultado = InternoRoleManager.Update(papel);

                if (resultado.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }

                else
                {
                    AddErrorsFromResult(resultado);
                }
            }
            return(View(pvm));
        }
コード例 #4
0
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Papel papel = InternoRoleManager.FindById(id);

            if (papel == null)
            {
                return(HttpNotFound());
            }

            var pvm = new PapelViewModel();

            pvm.Id   = papel.Id;
            pvm.Nome = papel.Name;

            return(View(pvm));
        }
コード例 #5
0
        public ActionResult Create(PapelViewModel model)
        {
            if (ModelState.IsValid)
            {
                Papel papel = new Papel {
                    Name = model.Nome
                };
                IdentityResult resultado = InternoRoleManager.Create(papel);

                if (resultado.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }

                else
                {
                    AddErrorsFromResult(resultado);
                }
            }
            return(View(model));
        }
コード例 #6
0
        public ActionResult Delete(Papel papel)
        {
            Papel p = InternoRoleManager.FindById(papel.Id);

            if (p != null)
            {
                IdentityResult resultado = InternoRoleManager.Delete(p);

                if (resultado.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }

                else
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
            }

            else
            {
                return(HttpNotFound());
            }
        }