public async Task <IActionResult> Post(WarehouseApiModel warehouse) { bool result; var item = _apiRepository.AddWarehouse(warehouse, out result); return(Ok(item)); }
public Warehouse AddWarehouse(WarehouseApiModel insertedWarehouse, out bool result) { var warehouse = new Warehouse() { Name = insertedWarehouse.Name, Adress = insertedWarehouse.Adress, Manager = insertedWarehouse.Manager, Telephone = insertedWarehouse.Telephone, WarehouseItems = new List <WarehouseItem>() }; context.Warehouses .Add(warehouse); result = context.SaveChanges() > 0; return(warehouse); }
public async Task <IActionResult> Put(WarehouseApiModel warehouse, int id) { var result1 = await _apiRepository.DeleteWarehouse(id); var result2 = false; if (result1 > 0) { var item = _apiRepository.AddWarehouse(warehouse, out result2); if (result2) { return(Ok(item)); } } return(BadRequest(new { Del = result1, Add = result2 })); }