コード例 #1
0
        public async Task <ActionResult <ShipperModel> > AddShipper(ShipperModel shipperModel)
        {
            var shipper = _mapper.Map <Shipper>(shipperModel);

            _shipperService.Add(shipper);

            if (await _shipperService.IsSavedToDb())
            {
                var persistedShipperModel = _mapper.Map <ShipperModel>(shipper);
                return(CreatedAtAction(nameof(GetShipper),
                                       new { shipperId = persistedShipperModel.ShipperId },
                                       persistedShipperModel));
            }

            return(BadRequest());
        }