public ActionResult FilterSaleStock(string payment, string toDate, string fromDate, int?statusID, int?pageNo) { SaleStockViewModel model = new SaleStockViewModel(); OrderShippingHanlder handler = new OrderShippingHanlder(); model.SearchItem = payment; model.toDate = toDate; model.frmDate = fromDate; model.statusId = statusID.Value > 0 ? statusID.Value : 0; pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalRecord = handler.GetAllSaleProductCount(payment, toDate, fromDate, statusID.Value); model.OrderRecord = handler.GetAllSaleProduct(payment, toDate, fromDate, statusID.Value, pageNo.Value); double bill = 0; foreach (var b in model.OrderRecord) { bill += b.totalBill; } ViewBag.totalBill = bill; if (model.OrderRecord != null) { model.Pager = new Pager(totalRecord, pageNo, 10); return(PartialView("_FilterSaleStock", model)); } return(PartialView("_FilterSaleStock", model)); }
public ActionResult Thankyou() { ApplicationDbContext _applicationDbContext = new ApplicationDbContext(); List <CartVM> cartList = Session["cart"] as List <CartVM>; if (cartList == null) { TempData["cartEmptyMessage"] = "Your Cart is Empty Now"; return(RedirectToAction("Index", "ClientSide")); } Order orderObj = new Order(); int orderID = 0; ShippingVM shipping = Session["shippingInfo"] as ShippingVM; var userId = User.Identity.GetUserId(); var userAccount = new ApplicationDbContext().Users.Where(x => x.Id == userId).SingleOrDefault(); OrderShippingHanlder orderShippingHanlder = new OrderShippingHanlder(); int orderShipId = orderShippingHanlder.AddShiping(shipping); using (ApplicationDbContext _context = new ApplicationDbContext()) { orderObj.orderStatusID = 1; orderObj.OrderShippingID = orderShipId; orderObj.createAt = DateTime.Now; orderObj.paymentType = shipping.paymentType; orderObj.userID = userId; orderObj.totalBill = Convert.ToDouble(cartList.Sum(x => x.Total)); _context.Orders.Add(orderObj); _context.SaveChanges(); orderID = orderObj.Id; OrderDetail objDetail = new OrderDetail(); foreach (var item in cartList) { objDetail.OrderId = orderID; objDetail.ProductID = item.ProductID; objDetail.ProductName = item.ProductName; objDetail.Price = item.Price; objDetail.Quantity = item.Quantity; objDetail.Total = item.Total; _context.OrderDetails.Add(objDetail); _context.SaveChanges(); } } ViewBag.ShoppingCartList = cartList.ToList(); ViewBag.grandTotal = orderObj.totalBill; string strBody = "Dear User " + userAccount.user_Name + ",<br> Thank you so much for shopping its Worth is ." + "<br/><br/>" + orderObj.totalBill + "<br/><br/><br/><b> Best Regards & Thanks</b>: MensBytes <br/>"; MB.sendEmailFunction(userAccount.Email, "Thankyou for shopping", strBody); Session["shippingInfo"] = null; Session["cart"] = null; return(View()); }