public string getMasterEmailTemplate(string TemplateName) { using (var db = new EGULFEntities()) { EmailTemplateModel TemplateData = new EmailTemplateModel(); TemplateData = (from t in db.EmailTemplate.ToList() where t.Name == TemplateName select new EmailTemplateModel { EmailTemplateId = t.EmailTemplateId, Name = t.Name, Html = t.Html, Module = t.Module, Description = t.Description }).FirstOrDefault(); if (TemplateData.Name != null) { return(TemplateData.Html); } else { return(null); } } }
private static void ApprovedBylevel(volunteer_profile volunteer, VolunteerRepository repository, volunteer_profile oVolunteer, ContextUser cu) { if (cu.EnumRole == EnumUserRole.Approver1) { oVolunteer.IsApprovedAtLevel1 = true; oVolunteer.ApprovedAtLevel1Comments = volunteer.ApprovedAtLevel1Comments; } if (cu.EnumRole == EnumUserRole.Approver2) { oVolunteer.IsApprovedAtLevel2 = true; oVolunteer.ApprovedAtLevel2Comments = volunteer.ApprovedAtLevel2Comments; } if (cu.EnumRole == EnumUserRole.Approver3) { oVolunteer.IsApprovedAtLevel3 = true; oVolunteer.ApprovedAtLevel3Comments = volunteer.ApprovedAtLevel3Comments; string password = EncryptionKeys.Decrypt(oVolunteer.user.Password); string url = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/Login"; var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Volunteer Approved", RedirectUrl = url, VolunteerName = oVolunteer.VolunteerName, UserName = oVolunteer.user.Username, Password = password }; string body = Util.RenderViewToString(bogusController.ControllerContext, "VolunteerApproved", emodel); EmailSender.SendSupportEmail(body, oVolunteer.VolunteerEmail); } repository.Put(oVolunteer.Id, oVolunteer); }
bool IEmailManager.SendRejectionEmailToUser(int recipientCardID, string reason) { var retVal = false; var CARD = Context.UserPostCardRecipients.Where(x => x.ID == recipientCardID).FirstOrDefault(); //Send welcome Email EmailTemplateModel emaildata = GetTemplate(Convert.ToInt32(TemplateTypes.RejectionEmail)); var lt = "<%"; var gt = "%>"; emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "NAME" + gt, CARD.UserPostCard.User.FirstName + ' ' + CARD.UserPostCard.User.LastName); emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "REASON" + gt, reason); var Domain = Config.Link; string rejurl = string.Format("{0}/Home/RejectionReason?id={1}", Domain, recipientCardID); emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "REJECTREASON" + gt, rejurl); if (CARD.UserPostCard.ShipmentDate.HasValue) { emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "DATE" + gt, CARD.UserPostCard.ShipmentDate.Value.ToString("MMM dd yyyy")); string url = string.Format("{0}/User/PostCard/ShowPostCard?postCardID={1}&userid={2}", Domain, CARD.UserPostCard.ID, CARD.UserPostCard.UserID); emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "URL" + gt, url); } var result = Utilities.SendEMail(CARD.UserPostCard.User.Email, emaildata.EmailSubject, emaildata.TemplateContent); if (result == true) { retVal = true; } return(retVal); }
public async Task <EmailTemplateModel[]> GetCampaignEmailTemplates( [FromRoute] string campaignId) { return((await _emailTemplateService.GetCampaignTemplatesAsync(campaignId)) .Select(t => EmailTemplateModel.Create(t)) .ToArray()); }
public ActionResult VolCorEvaluation(evaluation_volunteer_coordinator ecpp) { var repo = new EvaluationVolunteerCoordinatorRepository(); ecpp.RowGuid = Guid.NewGuid(); ecpp.CreatedAt = DateTime.Now; var cu = Session["user"] as ContextUser; if (cu.EnumRole == TmsWebApp.Common.EnumUserRole.Coordinator) { ecpp.IsCoordinator = false; var session = new SessionRepository().Get(ecpp.SessionId); var userId = session.CreatedBy; var admin = new AccountRepository().Get(userId); var corName = new CoordinatorRepository().Get(ecpp.CoordinatorId.Value).CoordinatorName; string url = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/Login/"; var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel model = new EmailTemplateModel { Title = "Evaluation Form Completion", VolunteerName = session.volunteer_profile.VolunteerName, CoordinatorName = corName, SessionTitle = session.ProgramName, User = admin.FirstName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "VolunteerFeedBack", model); EmailSender.SendSupportEmail(body, admin.Email); } else { ecpp.IsCoordinator = true; } repo.Post(ecpp); return(RedirectToAction("Index", "Session")); }
public IHttpActionResult SaveEmailTemplates(string data) { EmailTemplateModel emailTemplateObj = (EmailTemplateModel)Newtonsoft.Json.JsonConvert.DeserializeObject(System.Uri.UnescapeDataString(data), typeof(EmailTemplateModel)); EmailTemplatesRepository.UpdateEmailTemplate(emailTemplateObj); return(Ok()); }
public HttpResponseMessage saveemailTemplate(EmailTemplateModel aEmailTemplateModel) { List <EmailTemplateModel> result; try { if (this.ModelState.IsValid) { result = service.SaveEmailTemplate(aEmailTemplateModel); if (result != null) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { string message = "Error Saving Data"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public string GetHtmlBodyTemplate(EmailTemplateModel emailTemplateData, string msgType) { string body = string.Empty; string filePath = string.Empty; if (msgType == "Email") { filePath = Server.MapPath("~/Views/Shared/EmailTemplate.html"); StreamReader reader = new StreamReader(filePath); body = reader.ReadToEnd(); body = body.Replace("{UserName}", emailTemplateData.UserName); body = body.Replace("{Title}", emailTemplateData.Title); body = body.Replace("{Url}", emailTemplateData.Url); body = body.Replace("{Description}", emailTemplateData.Descriptions); } else { filePath = Server.MapPath("~/Views/Shared/EmailTemplate.html"); StreamReader reader = new StreamReader(filePath); body = reader.ReadToEnd(); body = body.Replace("{UserName}", emailTemplateData.UserName); body = body.Replace("{Title}", emailTemplateData.Title); body = body.Replace("{Url}", emailTemplateData.Url); body = body.Replace("{Description}", emailTemplateData.Descriptions); } return(body); }
public ActionResult Edit(volunteer_profile volunteer) { var repository = new VolunteerRepository(); var oVolunteer = repository.GetbyGuid(volunteer.RowGuid); var cu = Session["user"] as ContextUser; if (volunteer.SubmitButton == "reject") { oVolunteer.IsRejected = true; oVolunteer.RejectedBy = cu.OUser.Username; oVolunteer.ApprovedAtLevel1Comments = volunteer.ApprovedAtLevel1Comments; oVolunteer.ApprovedAtLevel2Comments = volunteer.ApprovedAtLevel2Comments; oVolunteer.ApprovedAtLevel3Comments = volunteer.ApprovedAtLevel3Comments; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Index")); } if (volunteer.SubmitButton == "otdate") { // oVolunteer.OTDateTime = DateTime.Parse(volunteer.OTDateString); oVolunteer.OTId = volunteer.OTId; oVolunteer.OTIdAssigner = cu.OUser.Id; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Index", new { status = "approved" })); } if (volunteer.SubmitButton == "accept") { //todo: send notification to super admin if (oVolunteer.OTIdAssigner != null) { var ot = new OTRepository().Get(oVolunteer.OTId.Value); var admin = new AccountRepository().Get(oVolunteer.OTIdAssigner.Value); var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Injaz: accepted by volunteer.", VolunteerName = oVolunteer.VolunteerName, User = admin.FirstName, OTSubject = ot.Subject }; string body = Util.RenderViewToString(bogusController.ControllerContext, "VolunteerAcceptsOT", emodel); EmailSender.SendSupportEmail(body, admin.Email); } oVolunteer.OTAcceptedByVolunteer = volunteer.OTAcceptedByVolunteer; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Edit", oVolunteer.RowGuid)); } if (volunteer.SubmitButton == "otattendense") { oVolunteer.OTAttendenceForVolunteer = volunteer.OTAttendenceForVolunteer; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Index", new { status = "approved" })); } ApprovedBylevel(volunteer, repository, oVolunteer, cu); return(RedirectToAction("Index")); }
public async Task <ActionResult> ChangeEmail(UpdateEmail em) { ToastModel tm = new ToastModel(); //string role = await _common.GetUserRoleName(User.Identity.Name); if (ModelState.IsValid) { //string uId = await _account.GetUserIdByEmail(User.Identity.Name); string uId = em.userId; bool isEmailExists = await _account.CheckIsEmailExists(em.Email); if (isEmailExists) { tm.IsSuccess = false; tm.Message = "Email already exists"; return(Json(tm)); } else { EncryptDecrypt objEncryptDecrypt = new EncryptDecrypt(); UpdateEmail emailM = await _user.GetEmailById(uId); string mailTo = emailM.Email; UpdateEmail emailModel = new UpdateEmail(); emailModel.userId = uId; emailModel.Email = em.Email; UserModel usrm = await _user.GetUserInfo(emailM.Email); HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/UpdateEmailAddress", emailModel, true); if (userResponseMessage.IsSuccessStatusCode) { EmailTemplateModel etm = await _account.GetEmailTemplate(1); string approvalLink = configMngr["UserActivationLink"] + objEncryptDecrypt.Encrypt(emailM.Email, configMngr["ServiceAccountPassword"]); string fullname = usrm.FirstName + " " + usrm.LastName; string emailBody = etm.Body .Replace("[Username]", fullname) .Replace("[URL]", approvalLink); etm.Body = emailBody; EmailManager emailmgr = new EmailManager { Body = etm.Body, To = mailTo, Subject = etm.Subject, From = ConfigurationManager.AppSettings["SMTPUsername"] }; emailmgr.Send(); } tm.IsSuccess = true; tm.Message = "Email updated successfully and an email has been sent to registered email. Please activate your account"; return(Json(tm)); } } return(RedirectToAction("EditUserEmail", "Common")); }
// // GET: /EmailTemplate/Create public ActionResult Create() { var model = new EmailTemplateModel(); model.CurrentMenu = PageInfo; model.MainMenu = _mainMenu; return(View("Create", model)); }
public async Task <JsonResult> SharedAccountRequest(ApproveRejectModel arm) { UserModel um = await _user.GetUserInfo(arm.Email); um.IsApproved = arm.IsApproved; um.Status = arm.IsApproved ? true : false; um.EmailConfirmed = um.Status; HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/PostUser", um, true); string status = arm.IsApproved ? "Approved" : "Rejected"; if (userResponseMessage.IsSuccessStatusCode) { EmailTemplateModel etm = await _account.GetEmailTemplate(3); string primaryAccountEmail = await _account.GetFamilyPrimaryAccountEmail(arm.Email); string fromUserFullname = await _user.GetUserFullName(primaryAccountEmail); string emailSubject = etm.Subject .Replace("[Status]", status); etm.Subject = emailSubject; string emailBody = etm.Body .Replace("[FromUsername]", fromUserFullname) .Replace("[ToUsername]", arm.FullName) .Replace("[AcceptanceStatus]", status); etm.Body = emailBody; EmailManager em = new EmailManager { Body = etm.Body, To = arm.Email, Subject = etm.Subject, From = ConfigurationManager.AppSettings["SMTPUsername"] }; em.Send(); if (arm.AreAddressDetailsMatched && arm.IsApproved) { FamilyMemberModel fm = new FamilyMemberModel(); fm.CellPhone = um.CellPhone; fm.DOB = um.DOB; fm.Email = um.Email; fm.FirstName = um.FirstName; fm.GenderData = um.GenderId; fm.LastName = um.LastName; fm.RelationshipData = 6; fm.UpdatedBy = await _account.GetUserIdByEmail(um.Email); HttpResponseMessage addFamilyMemberRes = await Utility.GetObject("/api/User/PostFamilyMember", fm, true); } } return(Json(new { IsSuccess = userResponseMessage.IsSuccessStatusCode })); }
private ActionResult BindEmailTemplate() { CMSHelper cmsHelper = new CMSHelper(); EmailTemplateModel objEmail = new EmailTemplateModel(); var List = cmsHelper.GetAllTemplates(1).ToList(); ActiveTemplateList = List.Where(x => x.Status == 1).ToList(); InActiveTemplateList = List.Where(x => x.Status == 0).ToList(); return(View("Index", Tuple.Create(ActiveTemplateList, InActiveTemplateList, objEmail))); }
private static void NewCoordinatorEmail(coordinator_profile coordinator) { string url = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/Login"; var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel model = new EmailTemplateModel { Title = "Complete Profile", RedirectUrl = url, UserName = coordinator.CoordinatorEmail, Password = EncryptionKeys.Decrypt(coordinator.user.Password), CoordinatorName = coordinator.CoordinatorName, User = coordinator.user.FirstName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "CoordinatorProfile", model); EmailSender.SendSupportEmail(body, coordinator.CoordinatorEmail); }
public async Task <IActionResult> Template([FromRoute] string name, [FromQuery] EmailTemplateModel model) { if (model.Preview) { return(View(name, model)); } var renderedEmail = await _viewRenderService.RenderToString($"EmailTemplate/{name}", model); return(Ok(renderedEmail)); }
public ActionResult Edit(int Id) { string rootPath = ConfigurationManager.AppSettings["WebsiteRootPathAdmin"]; CMSHelper cmsHelper = new CMSHelper(); EmailTemplateModel model = new EmailTemplateModel(); model = cmsHelper.GetTemplateByID(Id); // model.ConfigValue = model.ConfigValue.Replace("{BASEPATH}", rootPath); ViewBag.StatusList = AppLogic.BindDDStatus(Convert.ToInt32(model.Status)); return(View(model)); }
private void SchoolRegistrationEmail(coordinator_profile coordinator) { string url = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Coordinator/Register/" + coordinator.RowGuid; var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel model = new EmailTemplateModel { Title = "Coordinator Registraion ", RedirectUrl = url, CoordinatorName = coordinator.school.SchoolName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "CoordinatorRegistration", model); string file = Server.MapPath("~/Uploads/DocumentLibrary/DefaultDocument/CoordinatorRegister.docx"); EmailSender.SendSupportEmail(body, coordinator.CoordinatorEmail, file); }
public ActionResult MarkCompleted(session session) { var cu = Session["user"] as ContextUser; var sessionRepo = new SessionRepository(); var oSession = sessionRepo.Get(session.Id); if (Request.Form["SubmitButton"] == "Upload") { sessionRepo.RemoveSessionPhoto(session.Id); foreach (var item in session.EvaluationImageLink.Split(',').Where(x => !string.IsNullOrWhiteSpace(x))) { oSession.session_evaluationform_photo.Add(new session_evaluationform_photo { FilePath = item, FileExtension = Path.GetExtension(item) }); } foreach (var item in session.SessionImageLink.Split(',').Where(x => !string.IsNullOrWhiteSpace(x))) { oSession.session_photo.Add(new session_photo { FilePath = item, FileExtension = Path.GetExtension(item) }); } } else if (Request.Form["SubmitButton"] == "fillvolunteerevaluation") { int corId = new CoordinatorRepository().GetByUserId(cu.OUser.Id).Id; return(RedirectToAction("VolenteerForm", "EvaluationForm", new { sessionId = oSession.Id, volId = oSession.volunteer_profile.Id, corId = corId })); } else { oSession.MarkedCompletedByCoordinator = true; var volEmail = oSession.volunteer_profile.VolunteerEmail; var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Notification: coordinator session marked as completed.", CoordinatorName = oSession.school.coordinator_profile.FirstOrDefault().CoordinatorName, SessionTitle = oSession.ProgramName, VolunteerName = oSession.volunteer_profile.VolunteerName, User = oSession.school.user.FirstName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "CoordinatorMarkCompleted", emodel); EmailSender.SendSupportEmail(body, volEmail); var adminEmail = new AccountRepository().Get(oSession.CreatedBy).Email; EmailSender.SendSupportEmail(body, adminEmail); } sessionRepo.Put(oSession.Id, oSession); return(RedirectToAction("Index")); }
/// <summary> /// gets email template by template id /// </summary> /// <param name="id"> template id </param> /// <returns> email template model </returns> public EmailTemplateModel GetEmailTemplateByID(int id) { using (var _ctx = new ChinmayaEntities()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <EmailTemplate, EmailTemplateModel>(); }); IMapper mapper = config.CreateMapper(); EmailTemplateModel etm = new EmailTemplateModel(); return(mapper.Map(_ctx.EmailTemplates.FirstOrDefault(et => et.ID == id), etm)); } }
private List <EmailTemplateModel> LocalMapper(List <EmailTemplate> emailTemplatesNative) { List <EmailTemplateModel> emailTemplates = new List <EmailTemplateModel>(); foreach (var i in emailTemplatesNative) { EmailTemplateModel model = new EmailTemplateModel(); model.EmailLabel = i.EmailLabel; model.FromAddress = i.FromAddress; model.DateUpdated = i.DateUpdated.ToShortDateString(); emailTemplates.Add(model); } return(emailTemplates); }
public static void UpdateEmailTemplate(EmailTemplateModel updated) { BuildQuery qb = new BuildQuery(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()); qb.SetInParam("@EmailTemplateId", updated.EmailTemplateId, SqlDbType.UniqueIdentifier); qb.SetInParam("@TemplateName", updated.TemplateName, SqlDbType.VarChar); qb.SetInParam("@FromEmailId", updated.FromEmailId, SqlDbType.VarChar); qb.SetInParam("@ToEmailId", updated.ToEmailId, SqlDbType.VarChar); qb.SetInParam("@CCEmailId", updated.CCEmailId, SqlDbType.VarChar); qb.SetInParam("@Subject", updated.Subject, SqlDbType.VarChar); qb.SetInParam("@Body", updated.Body, SqlDbType.VarChar); qb.SetInParam("@ModifiedBy", updated.ModifiedBy, SqlDbType.UniqueIdentifier); long returnValue = qb.ExecuteNonQuery("spUpdateEmailTepmlate", CommandType.StoredProcedure); }
private EmailTemplateModel GetTemplate(int type) { var Template = Context.EmailTemplates.FirstOrDefault(z => z.TemplateType == type); if (Template != null) { EmailTemplateModel newModel = new EmailTemplateModel(); newModel = Mapper.Map <EmailTemplate, EmailTemplateModel>(Template, newModel); return(newModel); } else { return(null); } }
public void SetOccuredStatus() { var sessions = Context.sessions.Where(x => DateTime.Now > x.ActualDateTime.Value && x.Status == "Approved").ToList(); sessions.ForEach(x => x.Status = SessionStatus.Occured.ToString()); Context.SaveChanges(); foreach (var oSession in sessions) { var cor = oSession.school.coordinator_profile.First(); var volEmail = oSession.volunteer_profile.VolunteerEmail; var user = new AccountRepository().Get(oSession.CreatedBy); var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Notification: Session is occured.", SessionTitle = oSession.ProgramName, User = user.FirstName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "SessionOccured", emodel); EmailSender.SendSupportEmail(body, user.Email); emodel = new EmailTemplateModel { Title = "Notification: Session is occured.", SessionTitle = oSession.ProgramName, CoordinatorName = cor.CoordinatorName, }; body = Util.RenderViewToString(bogusController.ControllerContext, "SessionOccured", emodel); EmailSender.SendSupportEmail(body, cor.CoordinatorEmail); emodel = new EmailTemplateModel { Title = "Notification: Session is occured.", SessionTitle = oSession.ProgramName, VolunteerName = oSession.volunteer_profile.VolunteerName, }; body = Util.RenderViewToString(bogusController.ControllerContext, "SessionOccured", emodel); EmailSender.SendSupportEmail(body, volEmail); } }
public EmailTemplateModel GetEmailTemplate(EmailTemplate emailTemplate) { EmailTemplateModel emailTemplateModel = new EmailTemplateModel(); List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("@mappingName", emailTemplate.ToString()) }; var dtTemplate = DataExecutor.ExecuteDataTable(UtilityConstant.Procedures.Mst_GetEmailTemplateByMapping, param); if (dtTemplate != null && dtTemplate.Rows.Count > 0 && dtTemplate.Columns.Contains("EmailTemplate")) { emailTemplateModel.Template = dtTemplate.Rows[0]["EmailTemplate"].ToString(); emailTemplateModel.Subject = dtTemplate.Rows[0]["Subject"].ToString(); } return(emailTemplateModel); }
public void Configuration(IAppBuilder app) { ManagerService managerServcie = new ManagerService(); managerServcie.CheckAdmin(); OrderService os = new OrderService(); os.CheckContent(); SettingService emailTemplateSetting = new SettingService(); var emailTemplates = emailTemplateSetting.GetEmailTemplates(); if (emailTemplates?.Datas == null || emailTemplates.Datas.Count < 1) { var emailTempalte = new EmailTemplateModel { Id = 0, Body = "Dear Customer,\n\nWe recieved you order.\n\nThanks for your booking.\n\nDatanet", Subject = "Thanks for your booking" }; emailTemplateSetting.SaveEmailTemplate(emailTempalte); } // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888 Hangfire.GlobalConfiguration.Configuration.UseMemoryStorage(); app.UseHangfireServer(); app.UseHangfireDashboard(); HttpConfiguration config = new HttpConfiguration(); //Cors configuration config.EnableCors(new EnableCorsAttribute("*", "*", "*")); //Cookie configuration //app.UseCookieAuthentication( new CookieAuthenticationOptions() //{ // AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, // CookieName = "DATANETCMS", //}); app.UseOAuthBearerAuthentication(OAuthBearerOptions); WebApiConfig.Register(config); app.UseWebApi(config); }
public ActionResult Create(EmailTemplateModel model) { try { // TODO: Add insert logic here var data = AutoMapper.Mapper.Map <EMAIL_TEMPLATE>(model); data.CREATED_DATE = DateTime.Now; _emailTemplateBll.Save(data); TempData[Constans.SubmitType.Save] = Constans.SubmitMessage.Saved; return(RedirectToAction("Index")); } catch (Exception ex) { return(View(model)); } }
public async Task <ActionResult> UpdateEmailTemplate(EmailTemplateModel model) { if (!ModelState.IsValid) { return(PartialView("_EmailTemplateUpdatePartial", model)); } var result = await EmailTemplateWriter.UpdateEmailTemplate(model); if (!ModelState.IsWriterResultValid(result)) { return(PartialView("_EmailTemplateUpdatePartial", model)); } ViewBag.Success = result.Message; return(PartialView("_EmailTemplateUpdatePartial", model)); }
private static void SendEmailNotificationDateChanged(session oSession) { var cor = oSession.school.coordinator_profile.First(); var user = new AccountRepository().Get(oSession.CreatedBy); var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Injaz:Session Date Changed", CoordinatorName = cor.CoordinatorName, SessionTitle = oSession.ProgramName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "SessionDateChanged", emodel); EmailSender.SendSupportEmail(body, user.Email); }
public ActionResult Edit(EmailTemplateModel objEmail) { CMSHelper cmsHelper = new CMSHelper(); int count = cmsHelper.UpateTemplate(objEmail); if (count == 0) { TempData["CommonMessage"] = AppLogic.setMessage(count, "Email Template Updated Successfully."); return(RedirectToAction("Index")); } else { TempData["CommonMessage"] = AppLogic.setMessage(count, "Update Failed."); ModelState.AddModelError("ConfigValue", "Config Value is required."); return(View(objEmail)); } }
public async Task <JsonResult> ForgotPassword(ForgotPasswordModel model) { try { ToastModel tm = new ToastModel(); bool isEmailExists = await _account.CheckIsEmailExists(model.Email); if (isEmailExists) { EmailTemplateModel etm = await _account.GetEmailTemplate(8); EncryptDecrypt ed = new EncryptDecrypt(); string fullName = await _user.GetUserFullName(model.Email); string forgotPasswordResetLink = configMngr["ResetForgotPasswordLink"] + ed.Encrypt(model.Email, configMngr["ServiceAccountPassword"]); string emaiBody = etm.Body.Replace("[Username]", fullName) .Replace("[URL]", forgotPasswordResetLink); etm.Body = emaiBody; EmailManager em = new EmailManager { Body = etm.Body, To = model.Email, Subject = etm.Subject, From = ConfigurationManager.AppSettings["SMTPUsername"] }; em.Send(); tm.Message = "Email sent"; tm.IsSuccess = true; } else { tm.Message = "Email not found"; tm.IsSuccess = false; } return(Json(tm)); } catch (Exception e) { throw(e); } }
public EmailTemplate(EmailTemplateModel model) { Model = model; }