public async Task <IActionResult> Index() { string userId = _userManager.GetUserId(User); Basket basket = await _bsktManager.GetBasket(userId); CheckoutViewModel cvm = new CheckoutViewModel(); return(View(cvm)); }
public async Task <IActionResult> View(int id) { Product product = await _invManager.GetProductByID(id); if (_signInManager.IsSignedIn(User)) { Basket basket = await _bsktManager.GetBasket(_userManager.GetUserId(User)); ViewData["IsInBasket"] = _bsktManager.BasketHasItem(basket, id); } return(View(product)); }
public ActionResult <Basket> Get(int basketnumber) { logger.LogInformation($"Get called ({basketnumber})"); try { return(Ok(manager.GetBasket(basketnumber))); } catch (Exception e) { logger.LogError(e, $"Error at BasketController.Get({basketnumber})"); return(StatusCode(500, e.Message)); } }
/// <summary> /// Index of the basket, shows items that are currently in the user's basket /// </summary> /// <returns>the basket view</returns> public async Task <IActionResult> Index() { try { var user = _userManager.GetUserName(User); var basket = await _context.GetBasket(user); return(View(basket)); } catch (Exception e) { Console.WriteLine(e); return(null); } }
public IActionResult Charge([FromBody] ChargeViewModel model) { var basket = _basketManager.GetBasket(); basket.Customer = _mapper.Map <Customer>(model.Order.Customer); var paymentResult = _orderService.ProcessPayment(basket, model.Token); if (paymentResult.IsSuccessful) { _basketManager.ClearBasket(); return(Ok(paymentResult)); } return(BadRequest(paymentResult)); }
public async Task <IActionResult> Receipt(string address, string city, string zip) { ApplicationUser user = await _userManager.GetUserAsync(User); string userName = _userManager.GetUserName(User); Basket basket = await _context.GetBasket(userName); basket.TotalPrice = 0; foreach (var item in basket.BasketList) { basket.TotalPrice += item.LineItemAmount; } Order order = await _checkout.CreateOrder(user, basket.TotalPrice); order.Address = address; order.City = city; order.Zip = zip; await _checkout.UpdateOrder(order); foreach (var item in basket.BasketList) { await _checkout.CreateOrderItem(order, item); } order.OrderList = await _checkout.GetOrderItems(order.ID); Payment payment = new Payment(Configuration, _context); order.Completed = payment.Run(order); await _checkout.UpdateOrder(order); if (order.Completed == true) { await _checkout.SendRecieptEmail(user.Email); } return(View(basket)); }
public IActionResult GetBasket() { var viewModel = _mapper.Map <OrderViewModel>(_basketManager.GetBasket()); return(View(viewModel)); }
public IActionResult GetBasket(string buyerId) { return(Ok(_basketManager.GetBasket(buyerId))); }