public ActionResult _NewsletterAdd(Newsletter n, string InvisibleCaptchaValue)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                SF.LogError("_NewsletterAdd Captcha error");
                return(Content("Error: Captcha", "text/html"));
            }

            if (ModelState.IsValid)
            {
                n.NewsletterDate = DateTime.Now;
                _db.Newsletters.Add(n);
                _db.SaveChanges();
                SF.AddToNewsletter(n);

                return(Content(RP.GetTextComponent("_NewsletterAdd"), "text/html"));
            }
            else
            {
                SF.LogError("_NewsletterAdd Model not valid");
                return(Content("Error: Model not valid", "text/html"));
            }
        }
        public ActionResult _TextComponent(string SystemName)
        {
            object r = RP.GetTextComponent(SystemName);

            return(View(r));
        }
        public ActionResult _FormAdd(string InvisibleCaptchaValue, int FormID)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                SF.LogError("_FormAdd Captcha error");
                return(Content("Error: Captcha", "text/html"));
            }

            AbstractPage CurrentPage = _db.FormPages.FirstOrDefault(r => r.ID == FormID);

            if (CurrentPage == null)
            {
                ModelState.AddModelError(string.Empty, "CurrentPage error");
                SF.LogError("_FormAdd CurrentPage error");
                return(Content("Error: CurrentPage error", "text/html"));
            }

            Contact c = new Contact();

            List <FormField> l = CurrentPage.GetDataFromXML1 <FormField>().OrderBy(r => r.FormFieldOrder).ToList();

            foreach (Uco.Models.FormField item in l.OrderBy(r => r.FormFieldOrder))
            {
                if (string.IsNullOrEmpty(Request["form_item_" + item.FormFieldID.ToString()]))
                {
                    continue;
                }
                string t = Request["form_item_" + item.FormFieldID.ToString()];

                if (item.FormFieldType == FormField.FormFildType.Name && string.IsNullOrEmpty(c.ContactName))
                {
                    c.ContactName = t;
                }
                else if (item.FormFieldType == FormField.FormFildType.PhoneNumber && string.IsNullOrEmpty(c.ContactPhone))
                {
                    c.ContactPhone = t;
                }
                else if (item.FormFieldType == FormField.FormFildType.EmailAddress && string.IsNullOrEmpty(c.ContactEmail))
                {
                    c.ContactEmail = t;
                }
                else
                {
                    c.ContactData = c.ContactData + item.FormFieldTitle + ": " + t + "<br />";
                }
            }

            c.ContactReferal = SF.GetCookie("Referal");
            c.ContactUrl     = "<a target='_blank' href='http://" + Request.ServerVariables["HTTP_HOST"] + Request.UrlReferrer.ToString() + "'>" + Request.UrlReferrer.ToString() + "</a>";
            c.ContactDate    = DateTime.Now;

            _db.Contacts.Add(c);
            _db.SaveChanges();

            foreach (string item in RP.GetCurrentSettings().AdminEmail.Split(','))
            {
                if (!SF.isEmail(item.Trim()))
                {
                    continue;
                }

                _db.OutEmails.Add(new OutEmail
                {
                    MailTo  = item.Trim(),
                    Subject = Uco.Models.Resources.SystemModels.ContactMailSubject
                              .Replace("{ID}", c.ID.ToString())
                              .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]),
                    Body = Uco.Models.Resources.SystemModels.ContactMailBody
                           .Replace("{ID}", c.ID.ToString())
                           .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"])
                           .Replace("{ContactName}", c.ContactName)
                           .Replace("{ContactEmail}", c.ContactEmail)
                           .Replace("{ContactPhone}", c.ContactPhone)
                           .Replace("{ContactData}", c.ContactData)
                           .Replace("{ContactReferal}", c.ContactReferal)
                           .Replace("{ContactUrl}", c.ContactUrl),
                    TimesSent = 0,
                    LastTry   = DateTime.Now
                });
            }

            _db.SaveChanges();

            return(Content(RP.GetTextComponent("_FormAdd"), "text/html"));
        }
        public ActionResult _SmallFormAdd(ContactSmallForm csf, string InvisibleCaptchaValue)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                SF.LogError("_SmallFormAdd Captcha error");
                return(Content("Error: Captcha", "text/html"));
            }

            if (ModelState.IsValid)
            {
                Contact c = new Contact();

                c.ContactEmail = csf.ContactEmail;
                c.ContactName  = csf.ContactName;
                c.ContactPhone = csf.ContactPhone;

                c.ContactReferal = SF.GetCookie("Referal");
                string UrlReferrer = UcoString.GetUtf8String(Request.UrlReferrer.ToString());
                c.ContactUrl  = "<a target='_blank' href='" + UrlReferrer + "'>" + UrlReferrer + "</a>";
                c.ContactDate = DateTime.Now;

                _db.Contacts.Add(c);
                _db.SaveChanges();

                foreach (string item in RP.GetCurrentSettings().AdminEmail.Split(','))
                {
                    if (!SF.isEmail(item.Trim()))
                    {
                        continue;
                    }

                    _db.OutEmails.Add(new OutEmail
                    {
                        MailTo  = item.Trim(),
                        Subject = Uco.Models.Resources.SystemModels.ContactMailSubject
                                  .Replace("{ID}", c.ID.ToString())
                                  .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]),
                        Body = Uco.Models.Resources.SystemModels.ContactMailBody
                               .Replace("{ID}", c.ID.ToString())
                               .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"])
                               .Replace("{ContactName}", c.ContactName)
                               .Replace("{ContactEmail}", c.ContactEmail)
                               .Replace("{ContactPhone}", c.ContactPhone)
                               .Replace("{ContactData}", c.ContactData)
                               .Replace("{ContactReferal}", c.ContactReferal)
                               .Replace("{ContactUrl}", c.ContactUrl),
                        TimesSent = 0,
                        LastTry   = DateTime.Now
                    });
                }

                _db.SaveChanges();

                return(Content(RP.GetTextComponent("_SmallFormAdd"), "text/html"));
            }
            else
            {
                SF.LogError("_SmallFormAdd Model not valid");
                return(Content("Error: Model not valid", "text/html"));
            }
        }