public static void Error(string ex) { MailManagement.SendErrorMail(ex); ILog logger = Init(); logger.Error(ex); }
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()); }
public static void Fatal(Exception ex, Type classType) { string message = GetExceptionData(ex, classType); MailManagement.SendErrorMail(message); ILog logger = Init(); logger.Fatal(message); }
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()); }
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> </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> </td> </tr> <tr> <td style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; color: #777777;'>" + mailmessage + @"</td> </tr> <tr> <td> </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> </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> </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> </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> </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> </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> </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); }
public MailController() { _mailManagement = new MailManagement(); }
/// <summary> /// Post method for receiving User/Password. Server receive an HTTP message containing an 'User' object containing the User's code and pin used for authentication. /// Metodo Post per la ricezione di una coppia User/Password. Il server riceve un HTTP message che contiene un oggetto 'User' che contiene la matricola e il pin dell'Utente usati per l'autenticazione. /// </summary> /// <param name="u"></param> /// <returns></returns> public HttpResponseMessage Post(Utente u) { User ricerca = null; string msg = "OK"; bool login = true; HttpResponseMessage response = null; System.Net.HttpStatusCode httpStatusCode = System.Net.HttpStatusCode.Created; //inizializzazione db e ricerca utente in base alla matricola(codice) DatabaseManagement db = new DatabaseManagement(strConn, LogPath); try { int codice = Convert.ToInt32(u.User); ricerca = db.SelectSimpleUser(codice); if (ricerca == null) { //non ho trovato nessun utente semplice ricerca = db.SelectAdministrator(codice); } if (ricerca != null) { //converto in bytes la stringa da codificare byte[] data = Encoding.ASCII.GetBytes(u.Pwd); string result; SHA1 sha1 = new SHA1CryptoServiceProvider(); //ottengo lo SHA1 dei dati result = Encoding.ASCII.GetString(sha1.ComputeHash(data)); //confronto lo SHA1 della pwd inviata con lo SHA1 di quella nel DB if (result != ricerca.Password) { msg = "Invalid Password"; httpStatusCode = System.Net.HttpStatusCode.Unauthorized; login = false; } } else { msg = "Invalid Username"; httpStatusCode = System.Net.HttpStatusCode.Forbidden; login = false; } //utente e password corrispondono if (login) { //inserisco un record nella tabella degli ingressi db.InserAccessUser(ricerca.Codice, DateTime.Now, DatabaseManagement.LOGIN, null); //invio ad ogni amministratore una mail List <Administrator> AdminList = db.ShowAdministrators(); if (AdminList.Count > 0) { foreach (Administrator a in AdminList) { MailManagement mailmanagment = new MailManagement(a.MailAddress, a.MailPassword); mailmanagment.SendMailToAdmin(a.MailAddress, ricerca, DateTime.Now); } } } } catch (DatabaseException e)//DB exception { httpStatusCode = System.Net.HttpStatusCode.InternalServerError; msg = e.Mex; db.NewErrorLog("ANOMALY-" + e.Message, DateTime.Now); } catch (Exception e) { //in caso di errore la response diventa http 500 httpStatusCode = System.Net.HttpStatusCode.InternalServerError; msg = e.Message; db.NewErrorLog("ANOMALY-" + e.Message, DateTime.Now); } finally { db.CloseConnection(); response = Request.CreateResponse(httpStatusCode, msg); //aggiungo un messaggio allo status code response.ReasonPhrase = msg; } return(response); }