Exemple #1
0
        public ActionResult DeleteResourceById(int id)
        {
            AjaxResponse result = new AjaxResponse();

            try
            {
                if (id <= 0)
                {
                    result.Status = -1;
                    result.Message = "不存在该资源";
                }
                else
                {
                    resourceManager.DeleteResourceById(id);
                }
            }
            catch (Exception ex)
            {
                result.Status = -1;
                result.Message = ex.Message;
            }

            return Json(result);
        }
Exemple #2
0
        private ActionResult DeleteResources(string ids)
        {
            AjaxResponse result = new AjaxResponse();

            try
            {
                if (string.IsNullOrEmpty(ids))
                {
                    result.Status = -1;
                    result.Message = "请选择要删除的资源";
                }
                else
                {
                    List<int> idtodelete = new List<int>();
                    List<string> idslist = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    int temp = 0;
                    foreach (var id in idslist)
                    {
                        if (int.TryParse(id, out temp) && temp != 0)
                        {
                            idtodelete.Add(temp);
                        }
                    }
                    if (idtodelete.Count == 0)
                    {
                        result.Status = -1;
                        result.Message = "请选择要删除的资源";
                    }
                    else
                    {
                        resourceManager.DeleteResources(idtodelete);
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status = -1;
                result.Message = ex.Message;
            }

            return Json(result);
        }