public async Task <ServiceResponse <List <GetWarehouseDto> > > Add(PostWarehouseDto warehouseDto) { ServiceResponse <List <GetWarehouseDto> > serviceResponse = new ServiceResponse <List <GetWarehouseDto> >(); try { await _context.Warehouse.AddAsync(_mapper.Map <Warehouse>(warehouseDto)); await _context.SaveChangesAsync(); serviceResponse.Data = await GetAllWarehouses(); } catch (Exception e) { serviceResponse.Success = false; serviceResponse.Message = e.Message; } return(serviceResponse); }
public async Task <IActionResult> Add(PostWarehouseDto warehouseDto) => Ok(await _service.Add(warehouseDto));