// GET: ReportOrderHistories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TblOrderHistory tblOrderHistory = db.TblOrderHistories.Find(id);

            if (tblOrderHistory == null)
            {
                return(HttpNotFound());
            }
            return(View(tblOrderHistory));
        }
Esempio n. 2
0
        public ActionResult Cart(checkOutModel checkOutModel)
        {
            try
            {
                string body        = "";
                var    ToName      = "";
                var    ToEmail     = "";
                var    productName = (dynamic)null;
                var    StoreName   = "";
                var    Storelogo   = "";
                var    storeUrl    = "";
                var    j           = Convert.ToInt16(checkOutModel.productCount);

                var str     = geturl();
                var storeId = 0;

                if (str == "http://localhost:50279")
                {
                    storeId = 6;
                    var StoreInformation = db.TblStoreInformations.Where(e => e.StoreId == storeId).OrderByDescending(e => e.CreatedDate).FirstOrDefault();
                    storeId   = StoreInformation.StoreId;
                    ToName    = StoreInformation.Order_Notification_Name;
                    ToEmail   = StoreInformation.Order_Notification_Email;
                    Storelogo = StoreInformation.Logo;
                    storeUrl  = StoreInformation.StoreURL;
                    StoreName = StoreInformation.StoreName;
                }
                else
                {
                    var StoreInformation = db.TblStoreInformations.Where(e => e.IsActive == true && e.IsDelete == false && e.StoreURL == str).OrderByDescending(e => e.CreatedDate).FirstOrDefault();
                    storeId   = StoreInformation.StoreId;
                    ToName    = StoreInformation.Order_Notification_Name;
                    ToEmail   = StoreInformation.Order_Notification_Email;
                    Storelogo = StoreInformation.Logo;
                    storeUrl  = StoreInformation.StoreURL;
                    StoreName = StoreInformation.StoreName;
                }


                var productIds       = checkOutModel.ProductId.Split(';');
                var productAttribute = checkOutModel.productAttribute.Split(';');
                var ProductPrice     = checkOutModel.ProductPrice.Split(';');
                var productQuantity  = checkOutModel.productQuantity.Split(';');

                var             TotalSubPrice = checkOutModel.TotalSubPrice;
                TblOrderHistory tblOrderHistory;
                for (var i = 0; i < j; i++)
                {
                    tblOrderHistory = new TblOrderHistory();
                    var id = productIds[i].ToString();
                    tblOrderHistory.ProductID         = Convert.ToInt16(id);
                    tblOrderHistory.ProductAtrributes = productAttribute[i].ToString();
                    tblOrderHistory.ProductPrice      = ProductPrice[i].ToString();
                    tblOrderHistory.productQuantity   = productQuantity[i].ToString();

                    tblOrderHistory.OrderStatusID   = 3;
                    tblOrderHistory.TotalSubPrice   = checkOutModel.TotalPrice;
                    tblOrderHistory.TotalPrice      = checkOutModel.TotalPrice;
                    tblOrderHistory.comments        = checkOutModel.comments;
                    tblOrderHistory.StoreId         = storeId;
                    tblOrderHistory.OrderByName     = checkOutModel.EmployeeName;
                    tblOrderHistory.Phone           = checkOutModel.Phone;
                    tblOrderHistory.Email           = checkOutModel.Email;
                    tblOrderHistory.ShippingAddress = checkOutModel.ShippingAddress;
                    tblOrderHistory.country         = checkOutModel.country;
                    tblOrderHistory.state           = checkOutModel.state;
                    tblOrderHistory.postcode        = checkOutModel.postcode;
                    tblOrderHistory.CreatedDate     = DateTime.Now;
                    tblOrderHistory.ModifiedDate    = DateTime.Now;
                    db.TblOrderHistories.Add(tblOrderHistory);
                    db.SaveChanges();

                    productName = db.TblProducts.Find(tblOrderHistory.ProductID);
                    body        = body + "<tr style='background: #ffffff; color: #000; font-size:15px; text-align:left; font-family:Arial, Helvetica, sans-serif; vertical-align:top;'>" +
                                  "<td>" + tblOrderHistory.OrderID + " </td>" +
                                  "<td>" + productName.productTitle + " </td>" +
                                  "<td>" + tblOrderHistory.productQuantity + "</td>" +
                                  "<td>" + tblOrderHistory.ProductAtrributes + "</td>" +
                                  "</tr>";
                }

                //----------- mail send to client
                StreamReader sr        = new StreamReader(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/mail.html"));
                string       HTML_Body = sr.ReadToEnd();

                string final_Html_Body = HTML_Body.Replace("#name", ToName)
                                         .Replace("#moreRows", body)
                                         .Replace("#shippingAddress", checkOutModel.ShippingAddress)
                                         .Replace("#CustomerName", checkOutModel.EmployeeName)
                                         .Replace("#Phone", checkOutModel.Phone)
                                         .Replace("#imgsrc", "http://crastores.com" + Storelogo)
                                         .Replace("#StoreName", StoreName)
                                         .Replace("#visitStore", storeUrl)
                                         .Replace("#Comments", checkOutModel.comments)
                                         .Replace("#Email", checkOutModel.Email);

                sr.Close();

                string To           = ToEmail;
                string mail_Subject = "New Order Notification -" + StoreName;
                var    result       = BaseUtil.sendEmailer(To, mail_Subject, final_Html_Body);
                //----------- mail send to costomer
                StreamReader sr1        = new StreamReader(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/mailToCustomer.html"));
                string       HTML_Body1 = sr1.ReadToEnd();

                string final_Html_Body1 = HTML_Body1.Replace("#name", checkOutModel.EmployeeName)
                                          .Replace("#moreRows", body)
                                          .Replace("#shippingAddress", checkOutModel.ShippingAddress)
                                          .Replace("#CustomerName", checkOutModel.EmployeeName)
                                          .Replace("#Phone", checkOutModel.Phone)
                                          .Replace("#imgsrc", "http://crastores.com" + Storelogo)
                                          .Replace("#StoreName", StoreName)
                                          .Replace("#visitStore", storeUrl)
                                          .Replace("#Comments", checkOutModel.comments)
                                          .Replace("#Email", checkOutModel.Email);

                sr1.Close();

                string ToCustomerEmail   = checkOutModel.Email;
                string ToCustomerSubject = "New Order Notification -" + StoreName;
                var    result1           = BaseUtil.sendEmailer(ToCustomerEmail, ToCustomerSubject, final_Html_Body1);
                //----------- End mail send to costomer



                TempData["msg"] = "5";
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                TempData["msg"] = "6";
                // TempData["msg"] = ex.Message;
            }
            return(View());
        }