public async Task <Result <InventorySkuManageModel> > UpdateInventorySku([FromBody] InventorySkuManageModel model) { if (!Validate(model)) { return(null); } var item = await _mapper.FromModelAsync(model); var sUserId = _userManager.GetUserId(User); int userId; if (Int32.TryParse(sUserId, out userId)) { item.IdEditedBy = userId; } await _inventorySkuService.ValidateInventorySkuAsync(item); if (item.Id > 0) { item = await _inventorySkuService.UpdateAsync(item); } else { item = await _inventorySkuService.InsertAsync(item); } var toReturn = await _mapper.ToModelAsync <InventorySkuManageModel> (item); return(toReturn); }
public async Task <Result <InventorySkuManageModel> > GetInventorySku(string id) { int idINS = 0; if (id != null && !Int32.TryParse(id, out idINS)) { throw new NotFoundException(); } if (idINS == 0) { return(new InventorySkuManageModel() { StatusCode = RecordStatusCode.Active, }); } var item = await _inventorySkuService.SelectAsync(idINS); if (item == null) { throw new NotFoundException(); } InventorySkuManageModel toReturn = await _mapper.ToModelAsync <InventorySkuManageModel>(item); return(toReturn); }