예제 #1
0
        public ActionResult DeletAdmin(string ids)
        {
            List <int> idss = new List <int>();

            string[] idssp = ids.Split(',');
            foreach (var id in idssp)
            {
                if (id != "start")
                {
                    idss.Add(int.Parse(id));
                }
            }
            int      _total   = idss.Count();
            Response response = new Response();

            if (idss.Contains(int.Parse(CurrUser.UserID)))
            {
                return(Json(new Response()
                {
                    Code = 0, Message = "不能删除当前登录用户"
                }));
            }
            response = adminManager.Delete(idss);
            if (response.Code > 0)
            {
                response.Message = "共提交删除" + _total + "名管理员,实际删除" + response.Data + "名管理员.";
            }
            if (response.Code == 0)
            {
                response.Message = "共提交删除" + _total + "名管理员,实际删除" + response.Data + "名管理员. 删除失败!";
            }
            return(Json(response));
        }
        public async Task <IActionResult> Delete(int id)
        {
            if (id != 0)
            {
                OperationDetails result = await _adminManager.Delete(id);

                if (result.Succedeed)
                {
                    return(RedirectToAction("Categories", "Admin"));
                }
            }
            return(BadRequest());
        }
예제 #3
0
        public bool AdminDelete(ArgumentIterator iter)
        {
            var(hasValue, name) = iter.Advance();
            if (!hasValue)
            {
                Console.WriteLine("Missing username to delete from admins.");
                return(false);
            }

            if (!_adminManager.IsAdmin(name))
            {
                Console.WriteLine($"{name} is not an admin.");
                return(false);
            }

            _adminManager.Delete(name);
            Console.WriteLine($"{name} is no longer an admin.");
            Program.SaveConfig();
            return(true);
        }
예제 #4
0
 public IActionResult DeleteIngredient(string Id)
 {
     _adminManager.Delete(Id);
     return(RedirectToAction("Ingredients"));
 }