public ActionResult SendTicket(string toemail, string Content)
        {
            var subject = "Ticket";
            var toEmail = toemail;
            var body    = HttpUtility.UrlDecode(Content);

            MailManagement.SendEmail(subject, toEmail, body);
            return(new EmptyResult());
        }
Beispiel #2
0
        public ActionResult SendMesage(ContactSendViewModel vmContact)
        {
            var fromEmail = vmContact.email;
            var subject   = vmContact.subject;
            var toEmail   = ReadConfigData.GetAppSettingsValue("receivingContactEmail");
            var body      = "Dear sir, " + vmContact.message;

            MailManagement.SendEmail(subject, toEmail, body, fromEmail);
            return(RedirectToAction("Contact", "Home"));
        }
        public ActionResult TroubleLogin(string email)
        {
            var user = db.tblUserInformations.Where(c => c.Email == email).FirstOrDefault();

            if (user != null)
            {
                var subject = "Change Password";
                var toEmail = email;

                string baseUrl           = Request.Url.GetLeftPart(UriPartial.Authority);
                string changepasswordurl = baseUrl + "/Login/ChangePassword?userid=" + user.ID;
                var    body = changepasswordurl;

                MailManagement.SendEmail(subject, toEmail, body);
            }
            else
            {
                ModelState.AddModelError(" ", "Invalid Email");
            }
            return(View());
        }
Beispiel #4
0
        public string SaveOrder(string paymentid)
        {
            var ordertoken        = string.Empty;
            var checkOutViewModel = (CheckOutViewModel)Session["CheckOutViewModel"];

            _unitOfWork.BeginTransaction();
            try
            {
                var         productList = _productBusiness.GetListWT();
                OrderDetail order       = new OrderDetail();
                order.TokenKey  = GlobalMethods.GetToken();
                order.FirstName = checkOutViewModel.FirstNameShopper;
                order.LastName  = checkOutViewModel.LastNameShopper;
                order.Email     = checkOutViewModel.EmailShopper;
                order.Phone     = checkOutViewModel.PhoneShopper;
                //order.MobilePhone = checkOutViewModel.MobilePhoneShopper;
                //order.Address = checkOutViewModel.AddressShopper;
                //order.Pincode = checkOutViewModel.PincodeShopper;
                //order.City = checkOutViewModel.CityShopper;
                order.PaymentType = checkOutViewModel.PaymentType;
                order.PaymentId   = paymentid;
                //order.ShippingOrder = checkOutViewModel.ShippingOrder;
                order.OrderedBy   = "Guest";
                order.OrderStatus = "New";
                order.OrderDate   = DateTime.Now;
                order.OrderCode   = "";
                _OrderBusiness.Insert(order);
                _unitOfWork.SaveChanges();

                order.OrderCode = "OC" + order.OrderId;
                _OrderBusiness.Update(order);
                _unitOfWork.SaveChanges();

                ordertoken = order.TokenKey;

                //generating message
                var smsmessage  = "Thank you for your purchase. " + Environment.NewLine + "Your order code is:" + order.OrderCode + Environment.NewLine;
                var mailmessage = "Thank you for placing an order.<br>Your Order detail:<br>";
                mailmessage = mailmessage + "Order Code:" + order.OrderCode + "<br>";
                mailmessage = mailmessage + "Order Date:" + order.OrderDate.ToShortDateString() + "<br>";

                mailmessage = mailmessage + "Payment:" + order.PaymentType + "<br>";

                var itemdetailmessage = string.Empty;

                //Adding Order
                Decimal     totalAmount = 0;
                OrderedItem ordItem     = new OrderedItem();
                if (!string.IsNullOrEmpty(checkOutViewModel.OrderListJson))
                {
                    dynamic Obj = Newtonsoft.Json.JsonConvert.DeserializeObject(checkOutViewModel.OrderListJson);
                    foreach (var product in Obj)
                    {
                        var productId  = Convert.ToInt32(product.ProductID.ToString());
                        var sizeId     = Convert.ToInt32(product.SizeId.ToString());
                        var attributes = product.AttributeId.ToString();
                        var prdt       = productList.Where(c => c.ProductID == productId).FirstOrDefault();
                        ordItem.OrderId         = Convert.ToInt32(order.OrderId);
                        ordItem.ProductId       = productId;
                        ordItem.OrderQuantity   = product.Quantity;
                        ordItem.ProductName     = prdt.ProductName;
                        ordItem.Price           = _productBusiness.GetSelectedPrice(productId, sizeId, attributes);
                        ordItem.DiscountPercent = prdt.DiscountPercent;
                        ordItem.Size            = Convert.ToInt32(product.SizeId);
                        ordItem.Attributes      = product.AttributeId;
                        _OrderedItemBusiness.Insert(ordItem);
                        _unitOfWork.SaveChanges();
                        //formatting message
                        totalAmount       = totalAmount + (Math.Round((ordItem.Price ?? 0) - (Decimal.Divide(ordItem.DiscountPercent ?? 0, 100) * ordItem.Price ?? 0)) * ordItem.OrderQuantity);
                        itemdetailmessage = itemdetailmessage + @"<tr><td>" + prdt.ProductCode + "</td><td>" + prdt.ProductName + "</td><td>NRs " + (Math.Round((ordItem.Price ?? 0) - (Decimal.Divide(ordItem.DiscountPercent ?? 0, 100) * ordItem.Price ?? 0))) + "</td><td>" + ordItem.OrderQuantity + "</td><td>NRs " + (Math.Round((ordItem.Price ?? 0) - (Decimal.Divide(ordItem.DiscountPercent ?? 0, 100) * ordItem.Price ?? 0)) * ordItem.OrderQuantity) + "</td></tr>";
                    }
                }

                smsmessage = smsmessage + "And total amount is:$ " + totalAmount + Environment.NewLine + Environment.NewLine;
                smsmessage = smsmessage + "For further information please check your email." + Environment.NewLine + Environment.NewLine + "Ecommerce";

                Setting contactUs = db.Settings.AsNoTracking().FirstOrDefault();

                CookieStore mycookie           = new CookieStore();
                var         expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr"));
                mycookie.SetCookie(Enumerator.CustomerAction.AddToCart.ToString(), "", expireCookieTimeHr);

                _unitOfWork.Commit();

                Session.Remove("CheckOutViewModel");

                //sending order mail to customer
                string messageBody = @"<table style='border-collapse: collapse;' border='0' width='600' cellspacing='0' cellpadding='0' align='center'>
                                            <tbody>
                                                <tr>
                                                    <td>&nbsp;</td>
                                                </tr>      
                                                <tr>
                                                    <td>
                                                        <table style='border-collapse: collapse;' border='0' width='560' cellspacing='0' cellpadding='0' align='center'>
                                                            <tbody>
                                                                <tr>
                                                                    <td style='font-family: Arial, Helvetica, sans-serif; font-size: 16px; line-height: 22px; color: #777777;'>Dear <strong>" + order.FirstName + @"</strong>,</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>&nbsp;</td>
                                                                </tr>
                                                                <tr>
                                                                    <td style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; color: #777777;'>" + mailmessage + @"</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>&nbsp;</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Items Ordered</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <table>
                                                                            <thead>
                                                                                <tr>
                                                                                    <th>Product Code</th>
                                                                                    <th>Product Name</th>
                                                                                    <th>Price</th>
                                                                                    <th>Quantity</th>
                                                                                    <th>Total</th>
                                                                                </tr>
                                                                            </thead>
                                                                            <tbody>" + itemdetailmessage + @"</tbody>
                                                                            <tfoot>
                                                                                <tr>
                                                                                    <td colspan='4'>Subtotal</td>
                                                                                    <td>$ " + totalAmount + @"</td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td colspan='4'>Grand Total</td>
                                                                                    <td>$ " + totalAmount + @"</td>
                                                                                </tr>
                                                                            </tfoot>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>&nbsp;</td>
                                                                </tr>
                                                                <tr>
                                                                    <td style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; color: #a1004b; font-weight: bold;'>Regards,<br />Call Us On: " + contactUs.Phone + @" </td> </tr> <tr> <td>&nbsp;</td></tr>  </tbody>     </table>      </td>   </tr>   </tbody>   </table>";
                string subj        = "Order Product";
                string tomail      = order.Email;

                //sending order mail to customer service
                var messageBodycustomerservice = @"<table style='border-collapse: collapse;' border='0' width='600' cellspacing='0' cellpadding='0' align='center'>
                                            <tbody>
                                                <tr>
                                                    <td>&nbsp;</td>
                                                </tr>      
                                                <tr>
                                                    <td>
                                                        <table style='border-collapse: collapse;' border='0' width='560' cellspacing='0' cellpadding='0' align='center'>
                                                            <tbody>
                                                                <tr>
                                                                    <td style='font-family: Arial, Helvetica, sans-serif; font-size: 16px; line-height: 22px; color: #777777;'>Dear <strong>Customer Service</strong>,</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>&nbsp;</td>
                                                                </tr>
                                                                <tr>
                                                                    <td style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; color: #777777;'>" + order.FirstName + " has placed order. His/Her order code is: <strong>" + order.OrderCode + @"</strong></td>
                                                                </tr>
                                                                <tr>
                                                                    <td>&nbsp;</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Items Ordered</td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <table>
                                                                            <thead>
                                                                                <tr>
                                                                                    <th>Product Code</th>
                                                                                    <th>Product Name</th>
                                                                                    <th>Price</th>
                                                                                    <th>Quantity</th>
                                                                                    <th>Total</th>
                                                                                </tr>
                                                                            </thead>
                                                                            <tbody>" + itemdetailmessage + @"</tbody>
                                                                            <tfoot>
                                                                                <tr>
                                                                                    <td colspan='4'>Subtotal</td>
                                                                                    <td>$ " + totalAmount + @"</td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td colspan='4'>Grand Total</td>
                                                                                    <td >$ " + totalAmount + @"</td>
                                                                                </tr>
                                                                            </tfoot>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; color: #a1004b; font-weight: bold;'>With Regards,<br /></td>
                                                                </tr>
                                                                <tr>
                                                                    <td>&nbsp;</td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>";
                var subjcustomerservice        = "Order Product";
                var tomailcustomerservice      = ReadConfigData.GetAppSettingsValue("CustomerServiceEmail");

                //sending sms
                var mobileno = order.Phone;


                Task SendMailCustomer = Task.Factory.StartNew(() =>
                {
                    //sending mail to customer
                    MailManagement.SendEmail(subj, tomail, messageBody);
                    //sending message to customer service
                    MailManagement.SendEmail(subjcustomerservice, tomailcustomerservice, messageBodycustomerservice);
                    //send sms
                    //SendSMS.Send(mobileno, smsmessage);
                });
            }
            catch (Exception ex)
            {
                _unitOfWork.Rollback();
            }

            clearCart();
            return(ordertoken);
        }