예제 #1
0
        public async Task <IActionResult> BankDetail(int?id, Bank model)
        {
            var now = DateTime.Now;

            var result = new Result();


            if (model.Name.IsNullOrEmpty())
            {
                result.Error("请输入中文名称");
                return(Json(result));
            }

            if (id.HasValue && id.Value > 0)
            {
                var old = DefaultStorage.BankGet(id.Value);
                if (old == null)
                {
                    result.Message = "数据不存在";
                    return(Json(result));
                }

                var status = await TryUpdateModelAsync(old);

                if (status)
                {
                    result.Status = DefaultStorage.BankUpdate(old);
                    if (!result.Status)
                    {
                        result.Message = "更新失败";
                    }
                }
                else
                {
                    result.Message = "参数有误";
                }
                return(Json(result));
            }

            model.CreatedOn  = now;
            model.ModifiedBy = string.Empty;
            model.ModifiedOn = now;
            var newId = DefaultStorage.BankCreate(model);

            result.Status = newId > 0;
            if (result.Status)
            {
                result.Success();
            }

            return(Json(result));
        }