示例#1
0
        public async Task <IActionResult> Post(WarehouseApiModel warehouse)
        {
            bool result;
            var  item = _apiRepository.AddWarehouse(warehouse, out result);

            return(Ok(item));
        }
示例#2
0
        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);
        }
示例#3
0
        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 }));
        }