Example #1
0
        public JsonResult EditResult(Models.DataTableItemModel model)
        {
            if (ModelState.ValidateFail())
            {
                return(Json(DealResult.Wrong(ModelState.ValidateMessage())));
            }
            var data = GetDataSource().FirstOrDefault(o => o.Id == model.Id);

            if (data != null)
            {
                model.MapTo(data);
                model.DealUpload((file) =>
                {
                    data.File = FileLocation.Create(file.FileName, file.ContentType, "");
                }, () =>
                {
                    data.File = null;
                }, o => o.File);
                model.DealUpload((file) =>
                {
                    data.Files.Add(FileLocation.Create(file.FileName, file.ContentType, ""));
                }, (index) =>
                {
                    data.Files.RemoveAt(index);
                }, o => o.Files);
            }
            return(Json(DealResult.Refresh()));
        }
        public JsonResult Create(int parentId, Models.DataTableItemModel model)
        {
            if (ModelState.ValidateFail())
            {
                return(Json(DealResult.Wrong(ModelState.ValidateMessage())));
            }
            var data = new Models.DataTableItemModel();

            model.MapTo(data);

            if (GetDataSource(parentId).Count == 0)
            {
                data.Id = 1;
            }
            else
            {
                data.Id = GetDataSource(parentId).Max(o => o.Id) + 1;
            }
            model.DealUpload((file) =>
            {
                data.File = FileLocation.Create(file.FileName, file.ContentType, "");
            }, o => o.File);
            data.Files = new List <HttpPostedFileBase>();
            model.DealUpload((file) =>
            {
                data.Files.Add(FileLocation.Create(file.FileName, file.ContentType, ""));
            }, o => o.Files);
            GetDataSource(parentId).Insert(0, data);
            return(Json(DealResult.Refresh("添加成功")));
        }
        public JsonResult Remove(Guid[] selectedId)
        {
            if (selectedId == null || selectedId.Length == 0)
            {
                return(Json(DealResult.Refresh()));
            }
            var appClients   = new Application.AppClient();
            var actionResult = true;

            foreach (var item in selectedId)
            {
                if (!appClients.Remove(item))
                {
                    actionResult = false;
                }
            }
            if (actionResult)
            {
                return(Json(DealResult.Refresh()));
            }
            else
            {
                return(Json(DealResult.WrongRefresh("有帐单在引用,不能删除。")));
            }
        }
Example #4
0
 public JsonResult CreateResult(Models.TableEditModel model)
 {
     DataService.Instance.Add(new Data()
     {
         Name = model.Name, Avatar = DataFile.Create(model.File)
     });
     return(Json(DealResult.Refresh()));
 }
        public JsonResult CreateResult(Models.AppClientCreateModel model)
        {
            if (model.IdDisplay.HasValue)
            {
                new Application.AppClient().Create(model.IdDisplay.Value, model.Name, model.Description);
            }
            else
            {
                new Application.AppClient().Create(model.Name, model.Description);
            }

            return(Json(DealResult.Refresh()));
        }
Example #6
0
        public JsonResult Delete(params int[] id)
        {
            foreach (var item in id)
            {
                var model = GetDataSource().FirstOrDefault(o => o.Id == item);
                if (model == null)
                {
                    return(Json(DealResult.Wrong("没有删除项"), JsonRequestBehavior.AllowGet));
                }
                GetDataSource().Remove(model);
            }

            return(Json(DealResult.Refresh("删除成功"), JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public JsonResult ChangeResult(Models.TableEditModel model)
        {
            var data = DataService.Instance.Get(model.Id);

            if (data == null)
            {
                return(Json(DealResult.Refresh()));
            }
            model.DealUpload((file) =>
            {
                data.Avatar = DataFile.Create(file);
            }, Request.Form, () => {
            }, o => o.File);

            data.Name = model.Name;
            return(Json(DealResult.Refresh()));
        }
Example #8
0
 public JsonResult Create(Models.DataTableItemModel model)
 {
     return(Json(DealResult.Refresh("添加成功")));
 }
 public JsonResult EditResult(Models.AppClientEditModel model)
 {
     new Application.AppClient().Change(model.Id, model.Name, model.Description);
     return(Json(DealResult.Refresh()));
 }