// Update Shipping Address
        /// <summary>
        /// Update an existing Shipping Address in the database
        /// </summary>
        /// <param name="id"></param>
        /// <param name="shippingAddress"></param>
        /// <returns></returns>
        public IHttpActionResult Put([FromUri] int id, [FromBody] ShippingAddressUpdate shippingAddress)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateShippingAddressService();

            if (!service.UpdateShippingAddress(id, shippingAddress))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
        public bool UpdateShippingAddress(int id, ShippingAddressUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .ShippingAddresses
                    .Single(a => a.ShippingAddressId == id);

                entity.CustomerId    = model.CustomerId;
                entity.LocationName  = model.LocationName;
                entity.StreetAddress = model.StreetAddress;
                entity.StateId       = model.StateId;
                entity.ZipCodeId     = model.ZipCodeId;

                return(ctx.SaveChanges() == 1);
            }
        }