public async Task <ActionResult> Checkout(Order orderdetails) { if (ModelState.IsValid) { // Get user var userId = User.Identity.GetUserId(); // Save Order ShoppingCartManager shoppingCartManager = new ShoppingCartManager(this.sessionManager, this.db); var newOrder = shoppingCartManager.CreateOrder(orderdetails, userId); // Update informacje o profilach var user = await UserManager.FindByIdAsync(userId); TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); shoppingCartManager.EmptyCart(); // var order = db.Orders.Include("OrderItems").SingleOrDefault(o => o.OrderId == newOrder.OrderId); var order = db.Orders.Include("OrderItems").Include("OrderItems.GameInfo").SingleOrDefault(o => o.OrderId == newOrder.OrderId); return(RedirectToAction("OrderConfirmation")); } else { return(View(orderdetails)); } }
public async Task <ActionResult> Checkout(Order orderdetalis) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var newOrder = shoppingCartManager.CreateOrder(orderdetalis, userId); var user = await UserManager.FindByIdAsync(userId); TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); shoppingCartManager.EmptyCart(); var order = db.Orders.Include("OrderItems").Include("OrderItems.Album").SingleOrDefault(o => o.OrderId == newOrder.OrderId); string url = Url.Action("SendConfirmationEmail", "Manage", new { orderid = newOrder.OrderId, lastname = newOrder.LastName }); this.mailService.SendOrderConfirmationEmail(order); return(RedirectToAction("OrderConfirmation")); } else { return(View(orderdetalis)); } }
public async Task <ActionResult> Checkout(Order orderdetails) { if (ModelState.IsValid) { //logger.Info("Checking out"); // Get user var userId = User.Identity.GetUserId(); // Save Order //ShoppingCartManager shoppingCartManager = new ShoppingCartManager(this.sessionManager, this.db); var newOrder = shoppingCartManager.CreateOrder(orderdetails, userId); // Update profile information var user = await UserManager.FindByIdAsync(userId); TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); // Empty cart shoppingCartManager.EmptyCart(); return(RedirectToAction("OrderConfirmation")); } else { return(View(orderdetails)); } }
public async Task <ActionResult> Checkout(Order order) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var newOrder = shoppingCartManager.CreateOrder(order, userId); var user = await UserManager.FindByIdAsync(userId); // zrobi update ponizszej klasy bazujac na order ktory przyjdzie TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); shoppingCartManager.EmptyCart(); //jezeli trafiamy tutaj przez akcje post to robimy: // dzieki temu ze nie zwracam View uzytkownik bedzie mial opcje powrotu do poprzedniej strony bez utraty danych return(RedirectToAction("OrderConfirmation")); } else { return(View(order)); } }
public async Task <ActionResult> PaidCart(Order orderInformation) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var newOrder = shoppingCartManager.CreateOrder(orderInformation, userId); var user = await UserManager.FindByIdAsync(userId); TryUpdateModel(user.UserInformation); await UserManager.UpdateAsync(user); shoppingCartManager.ClearCart(); //var order = db.Orders.Include("OrderItems").Include("OrderItems.Product").SingleOrDefault(a => a.OrderID == newOrder.OrderID); var order = db.Orders.Include("OrderItems").SingleOrDefault(a => a.OrderID == newOrder.OrderID); // string url = Url.Action("SendConfirmationEmail", "Manage", new { orderID = newOrder.OrderID, surname = newOrder.Surname }, Request.Url.Scheme); ///BackgroundJob.Enqueue(() => Helpers.CallUrl(url)); this.mailService.SendOrderConfirmationEmail(order); return(RedirectToAction("PaymentPage", order)); } else { return(View(orderInformation)); } }
public async Task <ActionResult> Checkout(Zamowienie orderdetails) { if (ModelState.IsValid) { //logger.Info("Checking out"); // Get user var userId = User.Identity.GetUserId(); // Save Order ShoppingCartManager shoppingCartManager = new ShoppingCartManager(this.sessionManager, this.db); var newOrder = shoppingCartManager.CreateOrder(orderdetails, userId); // Update profile information var user = await UserManager.FindByIdAsync(userId); TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); // Empty cart shoppingCartManager.EmptyCart(); // Send mail confirmation // Refetch - need also albums details //var order = db.Orders.Include("OrderItems").SingleOrDefault(o => o.OrderId == newOrder.OrderId); ////var order = db.Zamowienia.Include("ZamowioneProdukty").Include("ZamowioneProdukty.Produkt").SingleOrDefault(o => o.ZamowienieId == newOrder.ZamowienieId); //IMailService mailService = new HangFirePostalMailService(); //mailService.SendOrderConfirmationEmail(order); //this.mailService.SendOrderConfirmationEmail(order); //string url = Url.Action("SendConfirmationEmail", "Cart", new { orderid = newOrder.OrderId, lastname = newOrder.LastName }, Request.Url.Scheme); //// Hangfire - nice one (if ASP.NET app will be still running) //BackgroundJob.Enqueue(() => Helpers.CallUrl(url)); //// Strongly typed - without background ////OrderConfirmationEmail email = new OrderConfirmationEmail(); ////email.To = order.Email; ////email.Cost = order.TotalPrice; ////email.OrderNumber = order.OrderId; ////email.FullAddress = string.Format("{0} {1}, {2}, {3}", order.FirstName, order.LastName, order.Address, order.CodeAndCity); ////email.OrderItems = order.OrderItems; ////email.CoverPath = AppConfig.PhotosFolderRelative; //// Loosely typed - without background ////dynamic email = new Postal.Email("OrderConfirmation"); ////email.To = order.Email; ////email.Cost = order.TotalPrice; ////email.OrderNumber = order.OrderId; ////email.FullAddress = string.Format("{0} {1}, {2}, {3}", order.FirstName, order.LastName, order.Address, order.CodeAndCity); ////email.OrderItems = order.OrderItems; ////email.CoverPath = AppConfig.PhotosFolderRelative; ////email.Send(); //// Easiest background ////HostingEnvironment.QueueBackgroundWorkItem(ct => email.Send()); return(RedirectToAction("OrderConfirmation")); } else { return(View(orderdetails)); } }
public async Task <ActionResult> Checkout(Order orderdetails) { if (ModelState.IsValid) { // logger.Info("Checking out"); // Get user var userId = User.Identity.GetUserId(); // Save Order ShoppingCartManager shoppingCartManager = new ShoppingCartManager(this.sessionManager, this.db); //pobierze dane zamowienia i id usera i powiaze je ze soba var newOrder = shoppingCartManager.CreateOrder(orderdetails, userId); // Update profile information var user = await UserManager.FindByIdAsync(userId); TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); // Empty cart shoppingCartManager.EmptyCart(); // Send mail confirmation // Refetch - need also products details //var order = db.Orders.Include("OrderItems").SingleOrDefault(o => o.OrderId == newOrder.OrderId); //zwroci wypelnione wlasciwowsci nawigacyjne //dot. produktu i zamowienia var order = db.Orders.Include("OrderItems").Include("OrderItems.Product").SingleOrDefault(o => o.OrderId == newOrder.OrderId); //imailservice mailservice = new hangfirepostalmailservice(); //mailservice.sendorderconfirmationemail(order); // this.mailservice.sendorderconfirmationemail(order); string url = Url.Action("SendConfirmationEmail", "Manage", new { orderid = newOrder.OrderId, lastname = newOrder.LastName }, Request.Url.Scheme); //// hangfire - nice one (if asp.net app will be still running) //BackgroundJob.Enqueue(() => Helpers.CallUrl(url)); //// Strongly typed - without background //ze strony postal OrderConfirmationEmail email = new OrderConfirmationEmail(); email.To = order.Email; email.Cost = order.TotalPrice; email.OrderNumber = order.OrderId; email.FullAddress = string.Format("{0} {1}, {2}, {3}", order.FirstName, order.LastName, order.Address, order.CodeAndCity); email.OrderItems = order.OrderItems; email.CoverPath = AppConfig.PhotosFolderRelative; email.Send(); return(RedirectToAction("OrderConfirmation")); //return new PartialViewAsPdf("_Checkout", order); } else { return(View(orderdetails)); } }
public async Task <ActionResult> Checkout(Order orderdetails) { if (ModelState.IsValid) { logger.Info("Checking out"); // Get user var userId = User.Identity.GetUserId(); //identyfiaktor pracownika wprowadzającego zlecenie // Save Order ShoppingCartManager shoppingCartManager = new ShoppingCartManager(this.sessionManager, this.db); var newOrder = shoppingCartManager.CreateOrder(orderdetails, userId); ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "NameAndSurname", orderdetails.CustomerId); ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "NameAndSurname", orderdetails.EmployeeId); var user = await UserManager.FindByIdAsync(userId); //TryUpdateModel(user.UserData); await UserManager.UpdateAsync(user); // Empty cart shoppingCartManager.EmptyCart(); // Send mail confirmation //var order = db.Orders.Include("OrderItems").SingleOrDefault(o => o.OrderId == newOrder.OrderId); var order = db.Orders.Include("ResultsOfOrderGRList").SingleOrDefault(o => o.OrderId == newOrder.OrderId); //IMailService mailService = new HangFirePostalMailService(); //mailService.SendOrderConfirmationEmail(order); this.mailService.SendOrderConfirmationEmail(order); //string url = Url.Action("SendConfirmationEmail", "Manage", new { orderid = newOrder.OrderId, lastname = newOrder.Email}, Request.Url.Scheme); // Hangfire - nice one (if ASP.NET app will be still running) //BackgroundJob.Enqueue(() => Helpers.CallUrl(url)); // Strongly typed - without background //OrderConfirmationEmail email = new OrderConfirmationEmail(); //email.To = order.Email; //email.Cost = order.TotalPrice; //email.OrderNumber = order.OrderId; //email.OrderItems = order.OrderItems; //email.ResultsOfOrderGRList = order.ResultsOfOrderGRList; //email.CoverPath = AppConfig.PhotosFolderRelative; //Loosely typed -without background //dynamic email = new Postal.Email("OrderConfirmation"); //email.To = order.Customer.Email; //email.Cost = order.TotalPrice; //email.OrderNumber = order.OrderId; //email.OrderItems = order.OrderItems; //email.CoverPath = AppConfig.PhotosFolderRelative; //email.Send(); //Easiest background //HostingEnvironment.QueueBackgroundWorkItem(ct => email.Send()); return(RedirectToAction("OrderConfirmation")); } else { return(View(orderdetails)); } }