using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net.Mail; using System.Web; using System.Web.Configuration; using System.Reflection; using System.Resources; using Yavsc.Model; using Npgsql.Web; using Npgsql.Web.Blog; using Yavsc.Helpers; using Yavsc; using System.Web.Mvc; namespace Yavsc.Controllers { /// /// Home controller. /// public class HomeController : Controller { // Site name private static string name = null; /// /// Gets or sets the site name. /// /// The name. [Obsolete("Use YavscHelpers.SiteName insteed.")] public static string Name { get { if (name == null) name = WebConfigurationManager.AppSettings ["Name"]; return name; } } /// /// Lists the referenced assemblies. /// /// The info. public ActionResult AssemblyInfo() { Assembly[] aslist = { GetType ().Assembly, typeof(ITCPNpgsqlProvider).Assembly, typeof(NpgsqlMembershipProvider).Assembly, typeof(NpgsqlContentProvider).Assembly, typeof(NpgsqlBlogProvider).Assembly }; List asnlist = new List (); foreach (Assembly asse in aslist) { foreach (AssemblyName an in asse.GetReferencedAssemblies ()) { if (asnlist.All(x=> string.Compare(x.Name,an.Name)!=0)) asnlist.Add (an); } } asnlist.Sort (delegate(AssemblyName x, AssemblyName y) { return string.Compare (x.Name, y.Name); }); return View (asnlist.ToArray()) ; } private static string owneremail = null; /// /// Gets or sets the owner email. /// /// The owner email. public static string OwnerEmail { get { if (owneremail == null) owneremail = WebConfigurationManager.AppSettings.Get ("OwnerEMail"); return owneremail; } set { owneremail = value; } } /// /// Index this instance. /// public ActionResult Index () { return View (); } public ActionResult Credits () { return View (); } /// /// Contact the specified email, reason and body. /// /// Email. /// Reason. /// Body. public ActionResult Contact (string email, string reason, string body) { if (email==null) ModelState.AddModelError("email","Enter your email"); if (reason==null) ModelState.AddModelError("reason","Please, fill in a reason"); if (body==null) ModelState.AddModelError("body","Please, fill in a body"); if (!ModelState.IsValid) return View (); // requires valid owner and admin email? if (OwnerEmail == null) throw new Exception ("No site owner!"); using (System.Net.Mail.MailMessage msg = new MailMessage(email,OwnerEmail,"[Contact] "+reason,body)) { msg.CC.Add(new MailAddress(YavscHelpers.Admail)); using (System.Net.Mail.SmtpClient sc = new SmtpClient()) { sc.Send (msg); YavscHelpers.Notice(ViewData, LocalizedText.Message_sent); return View (new { email=email, reason="", body="" }); } } } } }