Exemplo n.º 1
0
        public async Task <int> CreateAsync(AddWarehouseModel item)
        {
            if (await _warehouseRepository.IsCityUniqueAsync(item.City))
            {
                var warehouse = _mapper.Map <WarehouseModel, Warehouse>(item);
                await _warehouseRepository.CreateAsync(warehouse);

                return(warehouse.Id);
            }
            else
            {
                throw new System.Exception("Warehouse with this city name already exists");
            }
        }