public IActionResult StartProcessing() { OrderHeader orderHeader = _orderHRepo.FirstOrDefault(u => u.Id == OrderVM.OrderHeader.Id); orderHeader.OrderStatus = WC.StatusInProcess; _orderHRepo.Save(); TempData[WC.Success] = "Action completed successfully"; return(RedirectToAction(nameof(Index))); }
public IActionResult StartProcessing() { OrderHeader orderHeader = _orderHRepo.FirstOrDefault(x => x.Id == OrderVM.OrderHeader.Id); orderHeader.OrderStatus = WebConstants.StatusProcessing; _orderHRepo.Save(); TempData[WebConstants.Success] = "Order In Process!"; return(RedirectToAction(nameof(Index))); }
public IActionResult StartProcessing() { OrderHeader orderHeader = _order_header_repo.FirstOrDefault(u => u.Id == OrderVM.OrderHeader.Id); orderHeader.OrderStatus = MC.StatusInProcces; _order_header_repo.Save(); TempData[MC.Success] = "Order Is In Process"; return(RedirectToAction(nameof(Index))); }
public Task SaveOrderAsync(Order order) { return(Task.Factory.StartNew(() => { _orderRepository.Save(_orderEntityService.Map(order)); _mqPublisher.Send(order, "order", "order.add", "order.add"); })); }
public async Task <IActionResult> SummaryPost(ProductUserVM ProductUserVM) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); //we need to create an order OrderHeader orderHeader = new OrderHeader() { ApplicationUserId = claim.Value, FinalOrderTotal = ProductUserVM.ProductList.Sum(x => x.TempQty * x.Price), City = ProductUserVM.ApplicationUser.City, StreetAddress = ProductUserVM.ApplicationUser.StreetAddress, PostalCode = ProductUserVM.ApplicationUser.PostalCode, FullName = ProductUserVM.ApplicationUser.FullName, Email = ProductUserVM.ApplicationUser.Email, PhoneNumber = ProductUserVM.ApplicationUser.PhoneNumber, OrderDate = DateTime.Now, OrderStatus = WC.StatusPending }; _orderHRepo.Add(orderHeader); _orderHRepo.Save(); foreach (var prod in ProductUserVM.ProductList) { OrderDetail orderDetail = new OrderDetail() { OrderHeaderId = orderHeader.Id, PricePerUnit = prod.Price, Qty = prod.TempQty, ProductId = prod.Id }; var prodPopularity = _prodRepo.FirstOrDefault(u => u.Id == prod.Id); prodPopularity.ProductPopularity++; _prodRepo.Update(prodPopularity); _orderDRepo.Add(orderDetail); } _orderDRepo.Save(); TempData[WC.Success] = "Order is placed successfully"; return(RedirectToAction(nameof(OrderConfirmation), new { id = orderHeader.Id })); }
public int OrderSave(Order order_header) { if (order_header == null) { throw new ArgumentNullException(nameof(order_header)); } return(ExecuteFaultHandledOperation(() => { int order_header_key; var order_data = _order_se.Map(order_header); order_data.OrderItemCount = order_header.OrderItems.Sum(item => item.OrderItemQuantity); order_data.OrderValueSum = order_header.OrderItems.Sum(item => item.OrderItemLineSum); //order_data.OrderShipDate = order_header.OrderItems.Min(item => item.OrderItemShipDate).GetValueOrDefault(); order_header_key = _order_header_repo.Save(order_data); Log.Info($"Order Item start [{order_header.OrderItems.Count}] items to process"); foreach (var order_item in order_header.OrderItems) { var order_item_data = _order_item_se.Map(order_item); //Log.Info($"Order Item converted [{order_item_data.ProductName}] sucessfully!"); order_item_data.OrderKey = order_header_key; order_item_data.OrderItemKey = order_item.OrderItemKey; int order_item_key = _order_item_repo.Save(order_item_data); Log.Info($"Order Item [{order_item_key}] saved to the database sucessfully!"); } Log.Info($"Order Comments start [{order_header.Comments.Count}] items to process"); foreach (var comment in order_header.Comments) { comment.EntityKey = order_header_key; comment.EntityTypeKey = (int)QIQOEntityType.Order; int comment_key = _comment_be.CommentSave(comment); Log.Info($"Order Comment [{comment_key}] saved to the database sucessfully!"); } return order_header_key; })); }
public IActionResult SummaryPost(IFormCollection collection, ProductUserVM ProductUserVM) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); OrderHeader orderHeader = new OrderHeader() { CreatedByUserId = claim.Value, FinalOrderTotal = ProductUserVM.ProductList.Sum(x => x.Unit * x.Price), City = ProductUserVM.ApplicationUser.City, StreetAddress = ProductUserVM.ApplicationUser.StreetAddress, State = ProductUserVM.ApplicationUser.State, PostalCode = ProductUserVM.ApplicationUser.PostalCode, FullName = ProductUserVM.ApplicationUser.FullName, Email = ProductUserVM.ApplicationUser.Email, PhoneNumber = ProductUserVM.ApplicationUser.PhoneNumber, OrderDate = DateTime.Now, OrderStatus = WebConstant.StatusPending }; _orderHRepo.Add(orderHeader); _orderHRepo.Save(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> SummaryPost(IFormCollection collection, ProductUserVM ProductUserVM) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); if (User.IsInRole(WC.AdminRole)) { //we need to create an order //var orderTotal = 0.0; //foreach(Product prod in ProductUserVM.ProductList) //{ // orderTotal += prod.Price * prod.TempSqFt; //} OrderHeader orderHeader = new OrderHeader() { CreatedByUserId = claim.Value, FinalOrderTotal = ProductUserVM.ProductList.Sum(x => x.TempSqFt * x.Price), City = ProductUserVM.ApplicationUser.City, StreetAddress = ProductUserVM.ApplicationUser.StreetAddress, State = ProductUserVM.ApplicationUser.State, PostalCode = ProductUserVM.ApplicationUser.PostalCode, FullName = ProductUserVM.ApplicationUser.FullName, Email = ProductUserVM.ApplicationUser.Email, PhoneNumber = ProductUserVM.ApplicationUser.PhoneNumber, OrderDate = DateTime.Now, OrderStatus = WC.StatusPending }; _orderHRepo.Add(orderHeader); _orderHRepo.Save(); foreach (var prod in ProductUserVM.ProductList) { OrderDetail orderDetail = new OrderDetail() { OrderHeaderId = orderHeader.Id, PricePerSqFt = prod.Price, Sqft = prod.TempSqFt, ProductId = prod.Id }; _orderDRepo.Add(orderDetail); } _orderDRepo.Save(); string nonceFromTheClient = collection["payment_method_nonce"]; var request = new TransactionRequest { Amount = Convert.ToDecimal(orderHeader.FinalOrderTotal), PaymentMethodNonce = nonceFromTheClient, OrderId = orderHeader.Id.ToString(), Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; var gateway = _brain.GetGateway(); Result <Transaction> result = gateway.Transaction.Sale(request); if (result.Target.ProcessorResponseText == "Approved") { orderHeader.TransactionId = result.Target.Id; orderHeader.OrderStatus = WC.StatusApproved; } else { orderHeader.OrderStatus = WC.StatusCancelled; } _orderHRepo.Save(); return(RedirectToAction(nameof(InquiryConfirmation), new { id = orderHeader.Id })); } else { //we need to create an inquiry var PathToTemplate = _webHostEnvironment.WebRootPath + Path.DirectorySeparatorChar.ToString() + "templates" + Path.DirectorySeparatorChar.ToString() + "Inquiry.html"; var subject = "New Inquiry"; string HtmlBody = ""; using (StreamReader sr = System.IO.File.OpenText(PathToTemplate)) { HtmlBody = sr.ReadToEnd(); } //Name: { 0} //Email: { 1} //Phone: { 2} //Products: {3} StringBuilder productListSB = new StringBuilder(); foreach (var prod in ProductUserVM.ProductList) { productListSB.Append($" - Name: { prod.Name} <span style='font-size:14px;'> (ID: {prod.Id})</span><br />"); } string messageBody = string.Format(HtmlBody, ProductUserVM.ApplicationUser.FullName, ProductUserVM.ApplicationUser.Email, ProductUserVM.ApplicationUser.PhoneNumber, productListSB.ToString()); await _emailSender.SendEmailAsync(WC.EmailAdmin, subject, messageBody); InquiryHeader inquiryHeader = new InquiryHeader() { ApplicationUserId = claim.Value, FullName = ProductUserVM.ApplicationUser.FullName, Email = ProductUserVM.ApplicationUser.Email, PhoneNumber = ProductUserVM.ApplicationUser.PhoneNumber, InquiryDate = DateTime.Now }; _inqHRepo.Add(inquiryHeader); _inqHRepo.Save(); foreach (var prod in ProductUserVM.ProductList) { InquiryDetail inquiryDetail = new InquiryDetail() { InquiryHeaderId = inquiryHeader.Id, ProductId = prod.Id, }; _inqDRepo.Add(inquiryDetail); } _inqDRepo.Save(); TempData[WC.Success] = "Inquiry submitted successfully"; } return(RedirectToAction(nameof(InquiryConfirmation))); }