public async Task CreateProduct(ProductTO product) { Product p = new Product(product); await _productsRepository.CreateProduct(p); await _inventoryRepository.CreateInventory(new Inventory(p, product.Quantity, DateTime.Now)); }
public async Task <ActionResult <Inventory> > PostInventory([FromBody] Inventory inventory) { try { if (inventory is null) { return(BadRequest()); } _repo.CreateInventory(inventory); await _repo.SaveAsync(default).ConfigureAwait(false);
public IHttpActionResult CreateInventory(InventoryModel model) { if (ModelState.IsValid) { return(Ok(_inventoryRepository.CreateInventory(model))); } else { return(BadRequest(string.Join(", ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)))); } }
public async Task <Response <InventoryApiModel> > Handle(CreateInventoryCommand request, CancellationToken cancellationToken) { try { _repo.CreateInventory(request); await _repo.SaveAsync(cancellationToken).ConfigureAwait(false); var inventory = await _repo .GetInventoryBy(x => x.Name !.Equals(request.Name.ToUpperInvariant()) && x.Description !.Equals(request.Description !.ToUpperInvariant())); var result = new Response <InventoryApiModel>(inventory, ResponseStatus.Success); return(result); } catch (Exception e) { return(new Response <InventoryApiModel>(new InventoryApiModel(), ResponseStatus.Error, new { ErrorMessage = e.Message })); } }
public async Task CreateInventory(InventoryTO inventory) { inventory.DateLastUpdated = DateTime.Now; await _iInventoryRepository.CreateInventory(new Inventory(inventory)); }
public async Task <int> CreateInventory(Inventory Inventory) { return(await _IInventoryRepository.CreateInventory(Inventory)); }