public AuthController(IUserDB userDB, IUserDeviceDB userDeviceDB, ISessionDB sessionDB, SendMailService mailService) { _userDB = userDB; _userDeviceDB = userDeviceDB; _sessionDB = sessionDB; _sendMailService = mailService; }
public ActionResult ForgotPassword(ForgotPasswordmodel model) { var customer = CustomerService.GetCustomerByEmail(model.Email); if (customer == null) { ViewBag.error = "You are not registered yet"; return(View(model)); } var url = string.Format("/Account/ResetPassword/{0}", customer.ActivationCode); var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, url); string subject = "Forgot Password "; string header = EmailBody.MailHeader(subject, LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'> Dear User, </p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'> Please click on the following link in order to reset your account password.</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'><a href='" + link + "' style='text-decoration: none; color: #d21180;'> Forgot Password ! </a></p><br />"; body = body + "<p style='margin: 0px; padding: 0px 0px 0px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'><b>Cheers,</b> <br />" + LinkedInDemo.Class.AdminSiteConfiguration.SiteName + " Team</p>"; body = body + "</td></tr>"; //body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'><a href='" + link + "'> Forgot Password ! </a>"; //body = body + "</p><br/>"; //body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'>Cheers, <br />" + LinkedInDemo.Class.AdminSiteConfiguration.SiteName + " Team</p>"; string mailbody = header + body + footer; SendMailService.SendMail(model.Email, subject, mailbody); ViewBag.success = "Password reset link sent"; return(View(model)); }
public async Task <IActionResult> QuenMatKhau(QuenMatKhauRequest request) { int result = 0; string newPassword = SendMailService.GenerateString(); string newHashPassword = BCryptService.HashPassword(newPassword); result = await _userService.QuenMatKhau(request.tenDangNhap, request.email, newHashPassword); if (result == 1) { var subject = "Xác nhận quên mật khẩu"; StringBuilder body = new StringBuilder(); body.AppendFormat("Mật khẩu mới của bạn là: {0}", newPassword); try { var message = SendMailService.InitEmailMessage(request.email, subject, body.ToString()); SendMailService.SendMail(message); return(Ok(result)); } catch (Exception ex) { return(StatusCode(500)); } } return(NotFound()); }
public ActionResult CancelReservedRoom(string roomBookingID) { try { int bookingID = Int32.Parse(roomBookingID); RoomBooking roomBooking = db.RoomBookings.Where(x => x.RoomBookingID.Equals(bookingID)).Single(); if (roomBooking == null) { return(Json(new { Status = false }, JsonRequestBehavior.AllowGet)); } else { SendMailService mailService = new SendMailService(); HashCodeService hashCodeService = new HashCodeService(); String hashCode = hashCodeService.createRoomBookingCancelCode(bookingID, roomBooking.Email); mailService.toAddress = roomBooking.Email; //ND mail gui cho khach hang: mailService.body = "CANCEL ROOM BOOKING INFORMATION\n" + "CustomerName: " + roomBooking.Name + "\n" + "ID: " + roomBooking.RoomBookingID + "\n" + "CheckInDate: " + roomBooking.CheckinDate + "\n" + "CheckOutDate: " + roomBooking.CheckoutDate + "\n" + "Click here to cancel your booking: " + "http://localhost:8080/RoomBookings/DeleteRoomBooking/?id=" + roomBooking.RoomBookingID + "&hash=" + hashCode; mailService.subject = "CANCEL ROOM BOOKING INFORMATION"; mailService.sendMail(); return(Json(new { Status = true }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { Status = false }, JsonRequestBehavior.AllowGet)); } }
public void directcreditbyadmin(int CustomerId, string firstname, decimal ordertotal) { try { var subject = " Credits added to your account. "; var cust = CustomerService.GetCustomerById(CustomerId); var Email = cust.Email; var url = string.Format("/Dashboard/"); var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, url); string header = EmailBody.MailHeader(subject, LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p>Dear User,"; body = body + " " + ordertotal + " Credits is added to your account.<br/>Visit your dashboard to check and use these credits for your events.</p>"; body = body + "<a href='" + link + "'><button> Go To Dashboard </button></a><br/>"; body = body + "If you have any queries, please email us on [email protected].<br/>"; body = body + "Thank you for using EventNX."; body = body + "</td></tr>"; string mailbody = header + body + footer; SendMailService.SendMail(Email, subject, mailbody); } catch (Exception ex) { } }
public ActionResult ForgotUserPassoword() { SendMailService.SendMail(new Models.Email { Message = "Ninh dep trai", Subject = "this is subject", ToEmail = "*****@*****.**", ToName = "Ninh" }); return(Ok()); }
// send mail reset password public void sendMailResetPassword(string UserEmail) { SendMailService sendMailservice = new SendMailService(); string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/Common/ResetPassword.cshtml")); content = content.Replace("{{UserEmail}}", UserEmail); string subject = "Xác nhận thiết lập mật khẩu"; var callbackUrl = Url.Action("ConfirmResetPassword", "UserAccount", new { UserEmail = UserEmail }, protocol: Request.Url.Scheme); content = content.Replace("{{callback}}", callbackUrl); sendMailservice.SendMail(UserEmail, subject, content); // Gửi email đến tài khoản đăng kí }
public IHttpActionResult SendEmail(SendMailRequest mailModel) { try { SendMailService sendMailService = new SendMailService(); sendMailService.SendMail(mailModel); return(Ok("Mail Sent")); } catch (ObjectDisposedException ex) { throw ex; } }
public bool ValidateFromAddress() { if (Enabled == false) { return(true); } if (String.IsNullOrEmpty(FromAddress)) { return(false); } return(SendMailService.ValidateEmail(FromAddress)); }
public void SendMailWithTemplateTest() { SendMailService.SendMailWithTemplate( tos: new List <string> { "*****@*****.**" }, subject: "Subject", body: "Body", map: new Dictionary <string, object> { { "name", "テスト" }, { "message", "こんにちは" } }).Wait(); }
public ActionResult Edit(UserAccountModel model) { try { using (UserAccountService service = new UserAccountService()) { if (ModelState.IsValid) { bool isNew = false; SendMailService sendMailservice = new SendMailService(); if (model.USER_ID_HIDDEN == 0) { isNew = true; service.InsertUser(model); // send mail confirm account sendMailRegisterAccount(model); JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet); return(result); } else { isNew = false; service.UpdateUser(model); JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet); return(result); } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); foreach (var mes in ErrorMessages) { ModelState.AddModelError(mes.Key, mes.Errors.ToString()); } } return(new EmptyResult()); } } catch (Exception ex) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; System.Web.HttpContext.Current.Session["ERROR"] = ex; return(new EmptyResult()); } }
public void SendMailWithTemplateTest4() { SendMailService.SendMailWithTemplate( format: SendMailService.Format.Plane, tos: new List <string> { "*****@*****.**" }, subject: "Subject", body: "Body", map: new Dictionary <string, object> { { "name", "テスト" }, { "message", "プレーンメールのみ送りました" } }).Wait(); }
// send email confirm account public void sendMailRegisterAccount(UserAccountModel model) { SendMailService sendMailservice = new SendMailService(); string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/Common/Sendmail.cshtml")); content = content.Replace("{{UserEmail}}", model.USER_EMAIL); content = content.Replace("{{UserName}}", model.USER_NAME); content = content.Replace("{{Phone}}", model.USER_PHONE); string subject = "Xác nhận tài khoản mới"; var callbackUrl = Url.Action("ConfirmEmail", "UserAccount", new { UserEmail = model.USER_EMAIL }, protocol: Request.Url.Scheme); content = content.Replace("{{callback}}", callbackUrl); //var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString(); //sendMailservice.SendMail(toEmail, subject, content); sendMailservice.SendMail(model.USER_EMAIL, subject, content); // Gửi email đến tài khoản đăng kí }
public ActionResult Send(SendRequestModel request) { var response = new SendResponseModel(); //try to send email and make appropriate json object if not. response.Errors.AddRange(SendMailService.SendMail(request)); if (!response.Errors.Any()) { response.Message = "Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly."; } return(Json(response)); //? Json(new { status = "success", Message = "<p>Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly.</p><br>" }) //: Json(new { status = "error", Message = "<p>Error sending email.</p><br><p> Please make sure your information is correct.</p>" }); }
public async Task <ActionResult <int> > DangKyTaiKhoanKhachHang(DangKyRequest request) { var result = 0; string maTaiKhoan = GenerateMaTaiKhoan(request.Sdt); string password = SendMailService.GenerateString(); string hashPassword = BCryptService.HashPassword(password); string soTaiKhoan = GenerateSoTaiKhoan(request.Sdt); TaiKhoanDangNhapBO taiKhoanDangNhap = new TaiKhoanDangNhapBO(); taiKhoanDangNhap.MaTaiKhoan = maTaiKhoan; taiKhoanDangNhap.TenDangNhap = request.TenDangNhap; taiKhoanDangNhap.MatKhau = hashPassword; taiKhoanDangNhap.IdLoaiTaiKhoan = 1; TaiKhoanKhachHangBO taiKhoanKhachHang = new TaiKhoanKhachHangBO(); taiKhoanKhachHang.MaTk = maTaiKhoan; taiKhoanKhachHang.Sdt = request.Sdt; taiKhoanKhachHang.Email = request.Email; taiKhoanKhachHang.SoTaiKhoan = soTaiKhoan; taiKhoanKhachHang.TenTaiKhoan = request.HoTen; taiKhoanKhachHang.SoDu = 0; var themTaiKhoanResult = _userService.ThemTaiKhoanDangNhap(taiKhoanDangNhap); if (themTaiKhoanResult.Result == 1) { // Send mail after create success var subject = "Đăng ký tài khoản"; StringBuilder body = new StringBuilder(); body.AppendFormat("Mật khẩu của bạn là: {0}", password); var message = SendMailService.InitEmailMessage(request.Email, subject, body.ToString()); SendMailService.SendMail(message); result = _userService.ThemThongTinTaiKhoanKhachHang(taiKhoanKhachHang).Result; return(result); } else { return(StatusCode(500)); } }
public async Task <IActionResult> SendMailOTP(string email) { // Generate OTP var otp = SendMailService.GenerateOTP(); var subject = "[18HCB Banking] Mã xác nhận"; StringBuilder body = new StringBuilder(); body.AppendFormat("Mã xác nhận của bạn là: {0}", otp); try { var message = SendMailService.InitEmailMessage(email, subject, body.ToString()); SendMailService.SendMail(message); return(Ok(otp)); } catch (Exception ex) { return(StatusCode(500)); } }
public ActionResult CreateJSON(RoomBooking roomBooking) { /* * int RoomBookingID, int CustomerID, int Person, String RoomID, * string Name, string Phone, string Email, string CheckinDate, string CheckoutDate, string EmployeeID * * RoomBooking roomBooking = new RoomBooking(); * roomBooking.RoomBookingID = RoomBookingID; * roomBooking.CustomerID = CustomerID; * roomBooking.Person = Person; * roomBooking.RoomID = RoomID; * roomBooking.Name = Name; * roomBooking.Phone = Phone; * roomBooking.Email = Email; * roomBooking.CheckinDate = DateTime.Parse(CheckinDate); * roomBooking.CheckoutDate = DateTime.Parse(CheckoutDate); * roomBooking.EmployeeID = EmployeeID; */ System.Diagnostics.Debug.WriteLine(roomBooking.Person); System.Diagnostics.Debug.WriteLine(roomBooking.CheckoutDate); try { db.RoomBookings.Add(roomBooking); db.SaveChanges(); SendMailService mailService = new SendMailService(); mailService.toAddress = roomBooking.Email; mailService.body = "ROOM BOOKING INFORMATIION\n" + "CustomerName: " + roomBooking.Name + "\n" + "Phone:" + roomBooking.Phone + "\n" + "RoomBookingID for Customer: " + roomBooking.RoomBookingID + "\n" + "Person:" + roomBooking.Person + "\n" + "CheckIn:" + roomBooking.CheckinDate + "\n" + "CheckOut:" + roomBooking.CheckoutDate; mailService.subject = "RoomBooking Information"; mailService.sendMail(); return(Json(new { status = true, roomBookingID = roomBooking.RoomBookingID }, JsonRequestBehavior.AllowGet)); }catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetQuote(ContactUsModel model) { string subject = " New Inquiry for Credits "; string header = EmailBody.MailHeader(subject, LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p> <b>FullName :</b> " + model.FullName + " </p>"; body = body + "<p> <b>CompanyName :</b> " + model.CompanyName + " </p>"; body = body + "<p> <b>PhoneNumber :</b>" + model.PhoneNumber + " </p>"; body = body + "<p> <b>EmailAddress :</b>" + model.EmailAddress + " </p>"; body = body + "<p> <b>CreditsRequired : </b>" + model.CreditsRequired + " </p>"; body = body + "<p>Thanks and Cheers,<br />"; body = body + "The Entire EventNX team </p>"; string mailbody = header + body + footer; SendMailService.SendMail("[email protected],[email protected],[email protected]", subject, mailbody); // return View(model); return(Json("Success", JsonRequestBehavior.AllowGet)); }
public ActionResult Index(ContactUsModel model) { string subject = " New Inquiry "; string header = EmailBody.MailHeader(subject, LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p> <b>Name :</b> " + model.Name + " </p>"; body = body + "<p> <b>Company :</b> " + model.Company + " </p>"; body = body + "<p> <b>Designation :</b> " + model.Designation + " </p>"; body = body + "<p> <b>Phone :</b>" + model.Phone + " </p>"; body = body + "<p> <b>Email :</b>" + model.Email + " </p>"; body = body + "<p> <b>Message : </b>" + model.Message + " </p>"; body = body + "<p>Thanks and Cheers,<br />"; body = body + "The Entire EventNX team </p>"; string mailbody = header + body + footer; SendMailService.SendMail("[email protected],[email protected],[email protected]", subject, mailbody); return(View(model)); }
public void sendMailtoadmin(string firstname, string LastName, string CustEmail, string Contactno, string CompanyName, decimal ordertotal) { try { var subject = "New Credit Request"; var Email = db.Adminsettings.Select(a => a.Smtpusername).FirstOrDefault(); string header = EmailBody.MailHeader(subject, LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; text-align:left;'>" + " " + firstname + " " + LastName + " " + "has requested" + " " + ordertotal + " " + " to credit.</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 12px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'> User Details are :</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 12px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>" + CustEmail + " </p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 12px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>" + Contactno + " </p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 12px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;line-height: 22px;'>" + CompanyName + "</p>"; string mailbody = header + body + footer; SendMailService.SendMail("[email protected],[email protected],[email protected]", subject, mailbody); } catch (Exception ex) { } }
public void TestReportingEmail(SendMailService sendMailService) { if (!Model.ReportingModel.ValidateAcceptance()) { MessageBox.ShowError(Dialog, "Please correct error conditions before sending a test email.", Core.Application.NameAndVersion); } else { try { var m = Model.ReportingModel; sendMailService.SendEmail(m.FromAddress, m.ToAddress, "HFM.NET - Test Email", "HFM.NET - Test Email", m.Server, m.Port, m.Username, m.Password, m.IsSecure); MessageBox.ShowInformation(Dialog, "Test email sent successfully.", Core.Application.NameAndVersion); } catch (Exception ex) { Logger.Warn(ex.Message, ex); var text = String.Format("Test email failed to send. Please check your email settings.{0}{0}Error: {1}", Environment.NewLine, ex.Message); MessageBox.ShowError(Dialog, text, Core.Application.NameAndVersion); } } }
public void VerificationEmail(string firstname, string lastname, string email, string activationCode) { var url = string.Format("/Account/ActivationAccount/{0}", activationCode); var companywebsite = AdminService.GetAdminSetting(); var link = companywebsite.CompanyWebsite + url; //var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, url); string subject = "Please activate your EventNX account"; string header = EmailBody.MailHeader("Account Activation Email", LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'> Hello " + firstname + " " + lastname + ",</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>"; body = body + "Welcome to EventNX!</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'>"; body = body + "To activate your account, please click on the button below to verify your email address.</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>"; body = body + "<a href='" + link + "'><button style='background: #6F1855; color:#fff; border:none; padding:9px 20px; cursor: pointer;'> Activation Account ! </button></a></p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>Or paste this link intoyour browser:</ p > "; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'>"; body = body + "<a href='" + link + "' target='_blank' style='text-decoration: none; color: #d21180;'>" + link + "</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'>If you have any questions you can contact us at <a href='mailto:[email protected]' style='text-decoration: none; color: #d21180;'>[email protected]</a>.</ p > "; body = body + "<p style='margin: 0px; padding: 0px 0px 0px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'><b>Thanks and Cheers,</ b > <br />" + "The Entire EventNX team </p> "; body = body + "</td></tr>"; //body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;line-height: 22px;'>To activate your account, please click on the button below to verify your email address.</p>" + " <p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'><a href='" + link + "'><button> Activation Account ! </button></a></p>"; //body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>Or paste this link into your browser:"; //body = body + "</p><br/>"; //body = body + " <p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'>" + link + "</p>"; //body = body + "<br/>"; //body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'>If you have any questions you can contact us at [email protected] </p>"; //body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'>Thanks and Cheers, <br />" + "The Entire EventNX team </p>"; //body = body + "</td></tr>"; string mailbody = header + body + footer; SendMailService.SendMail(email, subject, mailbody); }
public void sendMailtocustomer(String Email, string subject, string firstname, int EventId, int amount) { try { EventMaster eventmaster = EventService.GetEventById(Convert.ToInt32(EventId)); //Email = db.Adminsettings.Select(a => a.Smtpusername).FirstOrDefault(); string header = EmailBody.MailHeader(subject, LinkedInDemo.Class.AdminSiteConfiguration.GetURL()); string footer = EmailBody.MailFooter(LinkedInDemo.Class.AdminSiteConfiguration.CompanyEmail); string body = "<tr>"; body = body + "<td style='text-align:left; padding: 0px 30px;'>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;'> Dear User,</p>"; //body = body + "<p style='text-align:left; padding: 0px 30px;'>Your credit request has been accepted for event " + eventmaster.EventName + ".</p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;line-height: 22px;'>Your request for " + amount + " credits have been received. We will get in touch with you shortly to address this request. Please look for our email on " + Email + " </p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 20px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000;line-height: 22px;'>If you have any queries, please email us on [email protected]. </p>"; body = body + "<p style='margin: 0px; padding: 0px 0px 0px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #000; line-height: 22px;'><b>Thanks and Cheers,</b><br />The Entire EventNX team </p>"; string mailbody = header + body + footer; SendMailService.SendMail(Email, subject, mailbody); } catch (Exception ex) { } }
public void SendMailWithTemplateTest2() { try { SendMailService.SendMailWithTemplate( tos: new List <string> { "*****@*****.**" }, subject: "Subject", body: "Body2", map: new Dictionary <string, object> { { "name", "テスト" }, { "message", "こんにちは" } }).Wait(); } catch (Exception e) { Assert.AreEqual("Web.config(またはApp.config)に key: Body2 を指定してください。", e.InnerException.Message); return; } Assert.Fail(); }
public ContestantController(IModelService ims, SendMailService s, UserRepository ur) { _mailService = s; _repo = ur; _modelServices = ims; }
/// <summary> /// Create Purchase Order : /// 1. Create Purchase Order /// 2. Add payment transaction /// </summary> /// <param name="_purchase"></param> /// <returns></returns> public int CreateOrUpdatePurchaseOrder(Purchase _purchase) { using (DataAccess da = new DataAccess()) { try { System.Collections.Generic.Dictionary <string, string> fields = new System.Collections.Generic.Dictionary <string, string>(); fields.Add("Id", _purchase.Id == 0 ? null : _purchase.Id.ToString()); fields.Add("ProductId", _purchase.ProductId.ToString()); fields.Add("BrandId", _purchase.BrandId.ToString()); fields.Add("ProductCode", _purchase.ProductCode); fields.Add("StockCode", _purchase.StockCode); fields.Add("ItemDesc", _purchase.ItemDesc); fields.Add("Quantity", Convert.ToString(_purchase.Quantity)); fields.Add("AvlQuantity", Convert.ToString(_purchase.AvlQuantity)); fields.Add("PurchasePrice", _purchase.PurchasePrice.ToString()); fields.Add("SalePrice", _purchase.SalePrice.ToString());//PurchaseProfitPercent //folderFields.Add("ProductImage", System.Text.Encoding.UTF8.GetString(imgByteArr)); fields.Add("PurchaseDate", _purchase.PurchaseDate.ToString(ConfigurationManager.AppSettings["DateTimeFormat"])); fields.Add("CreatedDate", DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"])); fields.Add("ModifiedDate", _purchase.Id == 0 ? null : DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"])); purchaseOrderId = da.InsertOrUpdateStockMaster(fields, _tableToAttach); if (purchaseOrderId > 0) { // adding Product Image //if (!string.IsNullOrEmpty(imageName)) //{ // //Initialize a file stream to read the image file // using (FileStream fs = new FileStream(@imageName, FileMode.Open, FileAccess.Read)) // { // //Initialize a byte array with size of stream // imgByteArr = new byte[fs.Length]; // //Read data from the file stream and put into the byte array // fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length)); // } // da.UpdateStockImage(imgByteArr, rslt, _tableToAttach); //} // add payment transaction PaymentTransaction paymentTransaction = new PaymentTransaction(); bool paymentStatus = paymentTransaction.AddPaymentTransaction(Global.UserId, _purchase.PurchasePrice * _purchase.Quantity, PaymentStatus.PURCHASE_PAYMENT, purchaseOrderId, da); if (paymentStatus) { SendMailService ms = new SendMailService(); ms.SendPurchaseOrderCreateMail(new Purchase() { Id = purchaseOrderId , TotalPurchasePrice = _purchase.PurchasePrice * _purchase.Quantity , PurchaseDate = _purchase.PurchaseDate }); MessageBoxResult result = MessageBox.Show("Stock Updated Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBoxResult result = MessageBox.Show((string)Application.Current.FindResource("StandardProcessingErrorMessage"), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { _logger.LogException(ex); da.RollbackTransaction(); } } return(purchaseOrderId); }
/// <summary> /// Create Sales Order : /// 1. Create Sale Person If New /// 2. Add SaleMaster /// 3. Add Sales Invoice /// 4. Add Pending Payment if any /// 5. Add payment transaction /// 6. Update Stock /// </summary> /// <returns></returns> public int CreateSalesOrder(Sale _sale) { int salesOrderId = 0; using (DataAccess da = new DataAccess()) { try { // add Sale Contact if (_sale.Contact.Id == 0) { _sale.Contact.Id = CreateSalePersonForSale(da, _sale.Contact); } if (_sale.Contact.Id > 0) { double total = _sale.Quantity * _sale.Price; bool isPending = (total > _sale.AmountPaid ? true : false); double pendingAmt = total - _sale.AmountPaid; #region Create Sales Master Object //Add SaleMaster Dictionary <string, string> saleMaster = new Dictionary <string, string>(); saleMaster.Add("Id", _sale.Id == 0 ? null : _sale.Id.ToString()); saleMaster.Add("StockId", _sale.StockId.ToString()); saleMaster.Add("SalePersonId", _sale.Contact.Id.ToString()); saleMaster.Add("Quantity", _sale.Quantity.ToString()); saleMaster.Add("Price", _sale.Price.ToString()); saleMaster.Add("Total", _sale.Total.ToString()); saleMaster.Add("AmountPaid", _sale.AmountPaid.ToString()); //saleMasterModel.Add("Pending", pendingAmt.ToString()); saleMaster.Add("SaleDate", _sale.SaleDate.ToString(ConfigurationManager.AppSettings["DateOnly"])); saleMaster.Add("CreatedDate", DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"])); #endregion salesOrderId = da.InsertOrUpdateSaleMaster(saleMaster, "tblSaleMaster"); if (salesOrderId > 0 && _sale.Id == 0) { #region Add Sales Invoice // Adding Sales Invoice Dictionary <string, string> invoice = new Dictionary <string, string>(); invoice.Add("Id", null); invoice.Add("SalesId", salesOrderId.ToString()); invoice.Add("InvoiceNumber", CommonMethods.GenerateInvoice(salesOrderId, _sale.SaleDate)); da.InsertOrUpdateInvoiceMaster(invoice, "tblInvoiceMaster"); #endregion #region Add Pending Payment if (isPending) { PendingPayment pendingPayment = new PendingPayment() { SaleId = salesOrderId, SalePersonId = _sale.Contact.Id, PendingAmount = pendingAmt , IsDiscount = _sale.IsDiscounted }; CreatePendingPayment(pendingPayment, da); } #endregion #region Add Payment Transaction // add payment transaction PaymentTransaction paymentTransaction = new PaymentTransaction(); bool paymentStatus = paymentTransaction.AddPaymentTransaction(Global.UserId, _sale.AmountPaid, CommonEnum.PaymentStatus.SALE_PAYMENT, salesOrderId, da); if (paymentStatus) { #region Update Stock Quantity Dictionary <string, string> stockModel = new Dictionary <string, string>(); stockModel.Add("Id", _sale.StockId.ToString()); stockModel.Add("AvlQuantity", _sale.Quantity.ToString()); stockModel.Add("ModifiedDate", DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"])); int isUpdated = da.UpdateStockQuantity(stockModel, "tblStockMaster"); #endregion if (isUpdated == 1) { SendMailService ms = new SendMailService(); ms.SendSalesOrderCreateMail(_sale); MessageBoxResult result = MessageBox.Show("Sale Added Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBoxResult result = MessageBox.Show("Error While Updating Stock!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBoxResult result = MessageBox.Show("Error While Adding Payment Transaction!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } #endregion } else { MessageBoxResult result = MessageBox.Show((string)Application.Current.FindResource("StandardProcessingErrorMessage"), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message); logger.LogException(ex); da.RollbackTransaction(); } } return(salesOrderId); }