示例#1
0
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = UserManager.FindById(id);

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

            GroupManager.ClearUserGroups(id);
            var result = UserManager.Delete(user);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("Error", result.Errors.First());
            }

            return(RedirectToAction("Index"));
        }
示例#2
0
        public IHttpActionResult DeleteUser(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var user = UserManager.FindById(id);

            if (user == null)
            {
                return(NotFound());
            }

            GroupManager.ClearUserGroups(id);
            var result = UserManager.Delete(user);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("Error", result.Errors.First());
            }

            return(Ok(user));
        }