Exemplo n.º 1
0
        public async Task <AjaxResult> Update([FromBody] InventoryInputDto dto)
        {
            return(await AjaxResult.Business(async result =>
            {
                Check.NotNull(dto, nameof(dto));

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

                dto.DateTime = DateTime.Now;
                await _inventoryContract.UpdateInventoryAsync(dto);
                result.Type = AjaxResultType.Success;
                if (dto == null)
                {
                    result.Error("找不到指定的库存信息");
                }
                else
                {
                    result.Success(dto);
                }
            }));
        }
        public async Task <bool> UpdateInventoryAsync(InventoryInputDto dto)
        {
            var inventory = dto.MapTo <Inventory>();
            await _inventoryRepo.UpdateAsync(inventory);

            return(true);
        }
        public async Task <bool> AddInventoryAsync(InventoryInputDto dto)
        {
            var inventory = dto.MapTo <Inventory>();
            await _inventoryRepo.InsertAsync(inventory);

            return(true);
        }
Exemplo n.º 4
0
        public async Task <AjaxResult> Add([FromBody] InventoryInputDto dto)
        {
            return(await AjaxResult.Business(async result =>
            {
                Check.NotNull(dto, nameof(dto));
                dto.Id = Guid.NewGuid();
                if (!ModelState.IsValid)
                {
                    result.Error("提交信息验证失败");
                    return;
                }

                dto.DateTime = DateTime.Now;
                await _inventoryContract.AddInventoryAsync(dto);
                result.Type = AjaxResultType.Success;
            }));
        }