Exemple #1
0
        public ActionResult Deletes(string strIds)
        {
            ResultMsg result = new ResultMsg();
            int       sum    = 0;

            if (!string.IsNullOrEmpty(strIds))
            {
                var commodityIds = strIds.Split(',');

                transaction.BeginTransaction();
                for (int i = 0; i < commodityIds.Length; i++)
                {
                    var comm = IGradesService.GetById(Convert.ToInt32(commodityIds[i]));
                    try
                    {
                        sum += IGradesService.Delete(comm);
                    }
                    catch (Exception)
                    {
                        result.CodeText = "不好意思,系统异常!";
                        return(Json(result));
                    }
                }
                transaction.Commit();
                if (sum == commodityIds.Length)
                {
                    result.Code     = 1;
                    result.CodeText = "删除成功!";
                }
                else
                {
                    result.Code     = 2;
                    result.CodeText = "删除失败!";
                }
                return(Json(result));
            }
            else
            {
                result.Code     = 2;
                result.CodeText = "请选中您要删除的级别!";
                return(Json(result));
            }
        }
Exemple #2
0
        public ActionResult Delete(int id)
        {
            ResultMsg result = new ResultMsg();
            var       comm   = IGradesService.GetById(id);

            if (comm != null)
            {
                IGradesService.Delete(comm);
                result.Code     = 1;
                result.CodeText = "删除成功!";
                return(Json(result));
            }
            else
            {
                result.Code     = 2;
                result.CodeText = "删除失败!";
                return(Json(result));
            }
        }
 public async Task Delete(int id)
 {
     await gradesService.Delete(id);
 }