public async Task <IActionResult> Details(int id) { if (_signInManager.IsSignedIn(User)) { //ViewBag.UserId = _userManager.GetUserId(User); var userId = _userManager.GetUserId(User); var user = await _userManager.FindByIdAsync(userId); var food = _foodData.GetFood(id); if (food == null) { return(RedirectToAction(nameof(Index))); } var orderFoodModel = new OrderFoodViewModel { Customer = user, CustomerOrder = food, }; return(View(orderFoodModel)); } else { return(RedirectToAction("Account", "Login")); } }
public async Task <IActionResult> Order(OrderFoodViewModel model) { var user = await _userManager.FindByIdAsync(model.Customer.Id); var food = _foodData.GetFood(model.CustomerOrder.Id); if (user == null) { ViewBag.ErrorMessage = $"The User Id {user} was not found"; return(View("Not Found")); } else if (food == null) { ViewBag.ErrorMessage = $"The Food Id {food} was not found"; return(View("Not Found")); } else { var newOrder = new Order { Customer = user, CustomerOrder = food, OrderDate = DateTime.Now, DeliveryAddress = model.DeliveryAddress, OrderStatus = "Pending Delivery", }; var orderFood = _foodData.OrderFood(newOrder); TempData["Message"] = "Order Successful"; return(RedirectToAction("Index", "Home")); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); PassengerViewModel = (PassengerViewModel)e.Parameter; OrderFoodViewModel = new OrderFoodViewModel(); OrderFoodViewModel.LoadOrderHistoryAsync(PassengerViewModel.Id); LayoutRoot.DataContext = new CollectionViewSource { Source = OrderFoodViewModel.OrderHistory }; }
private void ResultPaymentView_Loaded(object sender, RoutedEventArgs e) { OrderFoodViewModel orderFoodViewModel = OrderFoodViewModel.Instance; PaymentViewModel paymentViewModel = PaymentViewModel.Instance; TableViewModel tableViewModel = TableViewModel.Instance; tbTotalPrice.Text = string.Format("총 금액 : {0}", orderFoodViewModel.OrderFoodTotalPrice); tbOrderId.Text = string.Format("주문번호 : {0}", paymentViewModel.OrderId); orderFoodViewModel.InitInstance(); paymentViewModel.InitInstance(); tableViewModel.InitInstance(); DispatcherTimer timer = new DispatcherTimer(); timer.Tick += new EventHandler((object _sender, EventArgs _e) => { NavigationService.Navigate(new Uri("View/HomeView.xaml", UriKind.Relative)); timer.Stop(); }); timer.Interval = new TimeSpan(0, 0, 5); timer.Start(); }
private void ResetOrderFoodModelView() { var foodRepostitoryMock = new Mock <IRepository <FoodDTO> >(); _orderFoodViewModel = new OrderFoodViewModel(foodRepostitoryMock.Object, _orderRepositoryMock.Object); }