Example #1
0
        public async Task <IActionResult> CreateShipping([FromBody] ShippingResource shippingResource)
        {
            var shipping = mapper.Map <ShippingResource, Shipping>(shippingResource);

            repository.AddShipping(shipping);
            await unitOfWork.CompleteAsync();

            shipping = await repository.GetShippingById(shipping.Id);

            var result = mapper.Map <Shipping, ShippingResource>(shipping);

            return(Ok(result));
        }
Example #2
0
        public async Task <IActionResult> AddShipping([FromBody] SaveShippingResource saveShipping)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            saveShipping.ShippingCharge = shippingSettings.ShippingCharge;

            var shipping = mapper.Map <SaveShippingResource, Shipping>(saveShipping);

            shipping.ShippingCharge = shippingSettings.ShippingCharge;
            shipping.ShippingMethod = shippingSettings.ShippingMethod;
            shippingRepository.AddShipping(shipping);
            await unitOfWork.CompleteAsync();

            var shippingResource = mapper.Map <Shipping, ShippingResource>(shipping);

            return(Ok(shippingResource));
        }