Ejemplo n.º 1
0
        //Get Contact
        public ActionResult Contact(int id)
        {
            var items = new List <SelectListItem>();

            items.Add(new SelectListItem {
                Text = "Bitte wählen", Value = "", Selected = true
            });
            items.Add(new SelectListItem {
                Text = "Büro", Value = "1"
            });
            items.Add(new SelectListItem {
                Text = "Buchhaltung", Value = "2"
            });
            items.Add(new SelectListItem {
                Text = "Beiz/Umbruchbar", Value = "3"
            });
            items.Add(new SelectListItem {
                Text = "Booking", Value = "4"
            });
            items.Add(new SelectListItem {
                Text = "Fundbüro", Value = "5"
            });
            items.Add(new SelectListItem {
                Text = "Koko", Value = "6"
            });
            items.Add(new SelectListItem {
                Text = "Kultihalle", Value = "7"
            });
            items.Add(new SelectListItem {
                Text = "Trägerschaft", Value = "8"
            });
            items.Add(new SelectListItem {
                Text = "Vermietung", Value = "9"
            });
            items[id].Selected = true;
            ViewBag.Subject    = items;
            ViewBag.Showform   = "true";

            var random = new Random();
            var v      = new Cotcha();

            int  nr1       = random.Next(10);
            int  nr2       = random.Next(10);
            bool bOpreator = (DateTime.Now.Second % 2) == 1;

            v.Task = bOpreator ? "+" : "-";
            if (v.Task == "+")
            {
                v.Number1 = nr1;
                v.Number2 = nr2;
            }
            else
            {
                if (nr1 >= nr2)
                {
                    v.Number1 = nr1;
                    v.Number2 = nr2;
                }
                else
                {
                    v.Number1 = nr2;
                    v.Number2 = nr1;
                }
            }
            return(View(v));
        }
Ejemplo n.º 2
0
        public ActionResult Contact(Cotcha reslt, string msg, string titel, string name, int subject, string contact)
        {
            ViewBag.Showform = "false";
            bool ok = false;

            switch (reslt.Task)
            {
            case "+":
                if (reslt.Number1 + reslt.Number2 == reslt.Result)
                {
                    ok = true;
                }
                break;

            case "-":
                if (reslt.Number1 - reslt.Number2 == reslt.Result)
                {
                    ok = true;
                }
                break;
            }

            if (ok)
            {
                string sRecipient = "*****@*****.**";
                string sSubject   = string.Empty;
                switch (subject)
                {
                case 1:
                    sSubject = "Büro";
                    break;

                case 2:
                    sSubject   = "Buchhaltung";
                    sRecipient = "*****@*****.**";
                    break;

                case 3:
                    sSubject   = "Beiz/Umbruchbar";
                    sRecipient = "*****@*****.**";
                    break;

                case 4:
                    sSubject   = "Booking";
                    sRecipient = "*****@*****.**";
                    break;

                case 5:
                    sSubject   = "Fundbüro";
                    sRecipient = "*****@*****.**";
                    break;

                case 6:
                    sSubject   = "Koko";
                    sRecipient = "*****@*****.**";
                    break;

                case 7:
                    sSubject   = "Kultihalle";
                    sRecipient = "*****@*****.**";
                    break;

                case 8:
                    sSubject   = "Trägerschaft";
                    sRecipient = "*****@*****.**";
                    break;

                case 9:
                    sSubject   = "Vermietung";
                    sRecipient = "*****@*****.**";
                    break;
                }
                var m = new MailMessage();
                m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
                m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "*****@*****.**");
                m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "inf_frm%2%14");
                m.BodyFormat = MailFormat.Html;
                m.From       = "*****@*****.**";
                m.To         = sRecipient;
                m.Subject    = "Homepage: Kontaktaufnahme";
                m.Body       = titel + "<br/><br/>Thema: " + sSubject + "<br/><br/>" + msg.Replace("\n", "<br/>") + "<br/><br/>" +
                               "Von:<br/>" + name + "<br/>Kontakt: " + contact;
                SmtpMail.SmtpServer = "localhost";
                SmtpMail.Send(m);
                ViewBag.Message = "Danke, wir werden uns melden!";
            }
            else
            {
                ViewBag.Message = "Leider ist ein Rechnungsfehler aufgetreten..";
            }
            return(View());
        }