コード例 #1
0
ファイル: Utils.cs プロジェクト: NosDeveloper2/RecruitGenie
        /// <summary>
        /// This function returns the email after replaceing main template tags  Header/Body/Logo
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="emailBody"></param>
        /// <param name="replaceFooter"></param>
        /// <param name="replaceBody"></param>
        /// <param name="useCompanyFooter"></param>
        /// <returns></returns>
        public static string GetFullEmailReplacingMainTemplateTags(int userId, string emailBody, bool replaceFooter = false, bool replaceBody = true, bool useCompanyFooter = true)
        {
            // get the basic template
            var template = string.Empty;

            if (!File.Exists(HttpContext.Current.Server.MapPath("/_templates/" + "emailtemplate.html")))
                return template;
            template = File.ReadAllText(HttpContext.Current.Server.MapPath("/_templates/" + "emailtemplate.html"));

            // replace footer and header 
            //footer
            FooterTemplate userFooter = null;
            if (!useCompanyFooter && userId > 0)
                userFooter = new Users().GetFooterTemplate(userId);
            if (userFooter == null)
            {
                // get the default company footer
                userFooter = new FooterTemplate { Template = GetCompanyFooter() };
            }
            var footerTemplate = userFooter.Template;
            if (replaceFooter)
            {
                var user = new Users().GetUser(userId);
                footerTemplate = GetOriginalFooter(footerTemplate, userId, user);
            }

            template = template.Replace("#FOOTER#", footerTemplate);
            //replace the body
            if (replaceBody)
                template = template.Replace("#BODY#", emailBody);
            return template;
        }
コード例 #2
0
    /// <summary>
    /// Save User
    /// </summary>
    void SaveUser()
    {
        // save basic details
        var cUser = new ClientUser
          {
              ClientId = Convert.ToInt32(lblClientID.Text),
              Email = txtEmail.Text,
              ClientUserId = Convert.ToInt32(lblUserID.Text),
              JobTitle = txtJobTitle.Text,
              Telephone = txtTelephone.Text,
              Mobile = txtMobile.Text,
              Forename = txtForename.Text,
              Surname = txtSurname.Text,
              IsActive = rbtnActivatedYes.Checked,
              Password = !string.IsNullOrEmpty(txtPassword.Text) ? txtPassword.Text : "",
              UpdatedBy = Convert.ToInt32(lblUpdatingUserId.Text),
          };
        var emailTemplate = new FooterTemplate
        {
            ClientUserId = Convert.ToInt32(lblUserID.Text),
            InUse = true,
            Template = txtFooterTemplateHidden.Text
        };
        cUser.FooterTemplate = emailTemplate;

        var userId = new ClientUsers().AddEditClientUsers(cUser);

        if (userId > 0)
        {
            lblUserID.Text = userId.ToString();
            //save profile Image
            var link = txtProfileImageLink.Text;
            if (!string.IsNullOrEmpty(link))
            {
                new Documents().SaveDocuments(new List<Document> { new Document
                {
                    UploadUrl =  link,
                    FileName = "ProfilePic.jpg",
                    RefId = userId,
                    DocumentTypeValue = 10
                }});
            } 
        }
        LoadClientUser(userId); 
    }