private async void Standard_Tocart(object sender, System.EventArgs e) { PreferredClass preferred; Cart cart; cart = new Cart { CartID = 0, SeatNumber = null, PreferredClassID = Convert.ToInt32(Settings.Standard), ExtraID = null, Totalprice = Convert.ToInt32(Settings.NumberOfTravellers) * priceStandard, Quantity = Convert.ToInt32(Settings.NumberOfTravellers) }; await cartService.AddCart(cart); preferred = new PreferredClass { PreferredClassID = Convert.ToInt32(Settings.Standard), AirportID = Convert.ToInt32(Settings.AirportID), PreferredClassType = "Economy", FlightType = "Standard", Price = priceStandard, Quantity = allquantty - 1, Total = priceStandard * allquantty }; await preferredClass.UpdatePreferredClass(preferred.PreferredClassID, preferred); await DisplayAlert("Added to cart", "", "Ok"); Application.Current.MainPage = new FlightTravellers(); await PopupNavigation.Instance.PopAsync(true); }
private async void Flightbagcover(object sender, System.EventArgs e) { List <FlightExtra> flightExtras = await flightExtraservice.GetFlightExtras(); List <Cart> carts = await cartService.GetCart(); Cart cart; FlightExtra flightExtra; cart = new Cart { CartID = carts[0].CartID, ExtraID = flightExtras[0].ExtraID, PreferredClassID = carts[0].PreferredClassID, SeatNumber = null, Quantity = carts[0].Quantity, Totalprice = carts[0].Quantity * flightExtras[0].Price + carts[0].Totalprice }; await cartService.AddCart(cart); await cartService.UpdateCart(cart.CartID, cart); flightExtra = new FlightExtra { ExtraID = flightExtras[0].ExtraID, FlightextraType = flightExtras[0].FlightextraType, Price = flightExtras[0].Price, Quantity = flightExtras[0].Quantity - 1, TotalPrice = flightExtras[0].Quantity * flightExtras[0].Price }; Settings.FlightExtrass = flightExtras[0].Price.ToString(); Settings.FlightExtras0 = Settings.FlightExtrass; await flightExtraservice.UpdateflightExtras(flightExtra.ExtraID, flightExtra); await App.Current.MainPage.DisplayAlert("Added to cart", "", "Ok"); }
public IActionResult AddCart([FromBody] Item item) { if (HttpContext.Session.GetInt32("userId") == null) { return(new OkObjectResult(false)); } item.UserId = (int)HttpContext.Session.GetInt32("userId"); bool existed = CS.Check(item); if (existed) { CS.UpdateAddCart(item); return(new OkObjectResult(true)); } else { bool success = CS.AddCart(item); if (success) { return(new OkObjectResult(true)); } else { return(new OkObjectResult(false)); } } }
/// <summary> /// 立即购买 /// </summary> /// <param name="id"></param> /// <param name="num"></param> /// <returns></returns> public ActionResult BuyNow(string id, int num = 1) { var cs = new CartService(); string cartId = cs.AddCart(id, num); CookieHelper.SetCookie("cartids", string.Join(",", cartId)); return(Redirect("/cart/Settlement")); //return Redirect("/cart/Index");//立即购买跳转至购物车 }
private async void Button_Cart_Submit_Seat(object sender, EventArgs e) { List <SeatSelectionModel> seatSelections = selectionService.GetSeatSelections(); List <Cart> carts = await cartService.GetCart(); Cart cart; SeatSelectionModel seatSelectionModel; string de = "dd"; //Selected Front Row Function to add to cart cart = new Cart { CartID = carts[0].CartID, SeatNumber = allselectedseat, PreferredClassID = carts[0].PreferredClassID, ExtraID = null, Totalprice = FrontRowprice + carts[0].Totalprice, Quantity = carts[0].Quantity }; await cartService.AddCart(cart); await cartService.UpdateCart(cart.CartID, cart); seatSelectionModel = new SeatSelectionModel { SeatType = seattype, SeatNumber = allselectedseat, AirportID = Convert.ToInt32(Settings.AirportID), Price = FrontRowprice, Quantity = allquantity - 1, Total = FrontRowprice * Convert.ToInt32(Settings.NumberOfTravellers) }; await selectionService.UpdateSeatSelection(seatSelectionModel.SeatNumber, seatSelectionModel); await App.Current.MainPage.DisplayAlert("Added to cart", "", "Ok"); }
private async void Handle_clicked(object sender, System.EventArgs e) { PreferredClass preferredClasses; Cart cart; cart = new Cart { CartID = 0, SeatNumber = null, PreferredClassID = Convert.ToInt32(Settings.Business), ExtraID = null, Totalprice = Convert.ToInt32(Settings.NumberOfTravellers) * businessprice, Quantity = Convert.ToInt32(Settings.NumberOfTravellers) }; await cartService.AddCart(cart); preferredClasses = new PreferredClass { PreferredClassID = Convert.ToInt32(Settings.Business), AirportID = Convert.ToInt32(Settings.AirportID), PreferredClassType = "Business", FlightType = "Business", Price = businessprice, Quantity = allquantty - 1, Total = businessprice * allquantty }; await preferredClass.UpdatePreferredClass(preferredClasses.PreferredClassID, preferredClasses); await App.Current.MainPage.DisplayAlert("Added to cart", "", "Ok"); Application.Current.MainPage = new FlightTravellers(); await PopupNavigation.Instance.PopAsync(true); }
// POST: api/Carts public void Post([FromBody] Cart cart) { _cartService.AddCart(cart); }
public void AddCart(InCartVM inCartVM) { cartService.AddCart(inCartVM); }