// Create Shipping Address /// <summary> /// Create a new Shipping Address for a Customer /// </summary> /// <param name="shippingAddress"></param> /// <returns></returns> public async Task <IHttpActionResult> Post(ShippingAddressCreate shippingAddress) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateShippingAddressService(); var result = await service.CreateShippingAddress(shippingAddress); if (result == false) { return(InternalServerError()); } return(Ok()); }
//Create a new Shipping Address public async Task <bool> CreateShippingAddress(ShippingAddressCreate model) { var entity = new ShippingAddress() { ShippingAddressId = model.ShippingAddressId, CustomerId = model.CustomerId, LocationName = model.LocationName, StreetAddress = model.StreetAddress, StateId = model.StateId, ZipCodeId = model.ZipCodeId }; using (var ctx = new ApplicationDbContext()) { ctx.ShippingAddresses.Add(entity); return(await ctx.SaveChangesAsync() == 1); } }