)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Index (Ia.Ftn.Wa.Models.Contact)

Public general use code classes and xml files that we've compiled and used over the years:

Contact support class for Fixed Telecommunications Network (FTN) web application (Intranet) model.

    1: using System.Configuration;
    2: using System.Net;
    3: using System.Text;
    4: using System.Xml.Linq;
    5:  
    6: namespace Ia.Ftn.Wa.Models.Contact
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Contact support class for Fixed Telecommunications Network (FTN) web application (Intranet) model.
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2006-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public class Index
   28:     {
   29:         ////////////////////////////////////////////////////////////////////////////
   30:  
   31:         /// <summary>
   32:         ///
   33:         /// </summary>
   34:         public Index()
   35:         {
   36:         }
   37:  
   38:         /////////////////////////////////////////////////////////////////////////////////
   39:  
   40:         /// <summary>
   41:         ///
   42:         /// </summary>
   43:         public static Ia.Cl.Models.Result ProcessEmail(string nameTextInput, string emailTextInput, string phoneTextInput, string inquiryTextArea)
   44:         {
   45:             var result = new Ia.Cl.Models.Result();
   46:  
   47:             if (!string.IsNullOrEmpty(nameTextInput))
   48:             {
   49:                 if (!string.IsNullOrEmpty(emailTextInput))
   50:                 {
   51:                     if (Ia.Cl.Models.Default.IsEmail(emailTextInput))
   52:                     {
   53:                         if (!string.IsNullOrEmpty(inquiryTextArea))
   54:                         {
   55:                             //if (Ia.Cl.Models.Google.Recaptcha.Passed(Request.Form["g-recaptcha-response"]))
   56:                             //{
   57:                             var name = WebUtility.HtmlEncode(nameTextInput);
   58:                             var email = WebUtility.HtmlEncode(emailTextInput);
   59:                             var phone = WebUtility.HtmlEncode(phoneTextInput);
   60:                             var inquiry = WebUtility.HtmlEncode(inquiryTextArea);
   61:  
   62:                             result = SendMail(name, email, phone, inquiry);
   63:                             //}
   64:                             //else
   65:                             //{
   66:                             //    result.AddError("Captcha had failed.");
   67:                             //}
   68:                         }
   69:                         else
   70:                         {
   71:                             result.AddError("Please enter your inquiry.");
   72:                         }
   73:                     }
   74:                     else
   75:                     {
   76:                         result.AddError("Email is not in valid email format.");
   77:                     }
   78:                 }
   79:                 else
   80:                 {
   81:                     result.AddError("Please enter your email.");
   82:                 }
   83:             }
   84:             else
   85:             {
   86:                 result.AddError("Please enter your name.");
   87:             }
   88:  
   89:             return result;
   90:         }
   91:  
   92:         /////////////////////////////////////////////////////////////////////////////////
   93:  
   94:         /// <summary>
   95:         ///
   96:         /// </summary>
   97:         private static Ia.Cl.Models.Result SendMail(string name, string email, string phone, string inquiry)
   98:         {
   99:             var result = new Ia.Cl.Models.Result();
  100:  
  101:             var message = Ia.Ftn.Wa.Models.Ui.Default.MailTop();
  102:  
  103:             message += @"
  104: <p>A visitor to the website has an inquiry. Visitor information is below:</p>
  105:  
  106: <p>Visitor information:</p>
  107:  
  108: <table class=""form"">
  109: <tr><td>Name:</td><td>" + name + @"&nbsp;</td></tr>
  110: <tr><td>Email:</td><td>" + email + @"&nbsp;</td></tr>
  111: <tr><td>Phone:</td><td>" + phone + @"&nbsp;</td></tr>
  112: <tr><td></td><td></td></tr>
  113: <tr><td valign=""top"">Inquery:</td><td>" + inquiry + @"</td></tr>
  114: </table>";
  115:  
  116:             message += Ia.Ftn.Wa.Models.Ui.Default.MailBottom();
  117:  
  118:             var applicationContact = Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:ApplicationContact");
  119:             var applicationEmail = Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:ApplicationEmail");
  120:  
  121:             return Ia.Cl.Models.Smtp.SendHtml(applicationContact, applicationEmail, "A visitor to the website has an inquiry", message);
  122:         }
  123:  
  124:         /////////////////////////////////////////////////////////////////////////////////
  125:         /////////////////////////////////////////////////////////////////////////////////
  126:  
  127:         /// <summary>
  128:         ///
  129:         /// </summary>
  130:         protected Ia.Cl.Models.Result ProcessMailingList(string emailTextInput)
  131:         {
  132:             var result = new Ia.Cl.Models.Result();
  133:  
  134:             if (!string.IsNullOrEmpty(emailTextInput))
  135:             {
  136:                 if (Ia.Cl.Models.Default.IsEmail(emailTextInput))
  137:                 {
  138:                     //if (Ia.Cl.Models.Google.Recaptcha.Passed(Request.Form["g-recaptcha-response"]))
  139:                     //{
  140:                     var email = WebUtility.HtmlEncode(emailTextInput);
  141:  
  142:                     result = SendMail("Unknown", email, string.Empty, "Request to join mailing list");
  143:                     //}
  144:                     //else
  145:                     //{
  146:                     //    result.AddError("Captcha had failed.");
  147:                     //}
  148:                 }
  149:                 else
  150:                 {
  151:                     result.AddError("Your email is not in valid email format.");
  152:                 }
  153:             }
  154:             else
  155:             {
  156:                 result.AddError("Please enter your email.");
  157:             }
  158:  
  159:             return result;
  160:         }
  161:  
  162:         ////////////////////////////////////////////////////////////////////////////
  163:         ////////////////////////////////////////////////////////////////////////////
  164:     }
  165:  
  166:     ////////////////////////////////////////////////////////////////////////////
  167:     ////////////////////////////////////////////////////////////////////////////   
  168: }