コード例 #1
0
        public async Task <AjaxResult> Update([FromBody] MaterialInputDto dto)
        {
            return(await AjaxResult.Business(async result =>
            {
                Check.NotNull(dto, nameof(dto));

                if (!ModelState.IsValid)
                {
                    result.Error("提交信息验证失败");
                    return;
                }

                if (String.IsNullOrWhiteSpace(dto.Operator))
                {
                    dto.Operator = User.Identity.Name;
                }
                dto.DateTime = DateTime.Now;
                await _materialContract.UpdateMaterialAsync(dto);
                result.Type = AjaxResultType.Success;
                if (dto == null)
                {
                    result.Error("找不到指定的原料信息");
                }
                else
                {
                    result.Success(dto);
                }
            }));
        }
コード例 #2
0
 public async Task <AjaxResult> Add([FromBody] MaterialInputDto dto)
 {
     return(await AjaxResult.Business(async result =>
     {
         Check.NotNull(dto, nameof(dto));
         dto.Id = Guid.NewGuid();
         if (!ModelState.IsValid)
         {
             result.Error("提交信息验证失败");
             return;
         }
         if (String.IsNullOrWhiteSpace(dto.Operator))
         {
             dto.Operator = User.Identity.Name;
         }
         dto.DateTime = DateTime.Now;
         await _materialContract.AddMaterialAsync(dto);
         result.Type = AjaxResultType.Success;
     }));
 }
コード例 #3
0
        public async Task <bool> UpdateMaterialAsync(MaterialInputDto dto)
        {
            var material = dto.MapTo <Material>();

            return(await _materialRepo.UpdateAsync(material) > 0);
        }
コード例 #4
0
        public async Task <bool> AddMaterialAsync(MaterialInputDto dto)
        {
            var material = dto.MapTo <Material>();

            return(await _materialRepo.InsertAsync(material) > 0);
        }