Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            string diaryid = "";

            if (context.Request.HttpMethod == "GET")
            {
                foreach (string key in context.Request.QueryString.AllKeys)
                {
                    switch (key)
                    {
                    case "diaryid":
                        diaryid = context.Request.QueryString[key];
                        break;

                    default:
                        // You can use the default case.
                        break;
                    }
                }
            }

            Models.PetsDataContext db = new Models.PetsDataContext();

            var linqregisters = db.sp_DeleteDiary(Convert.ToInt32(diaryid));



            context.Response.ContentType = "text/plain";
            context.Response.Write("Diary entry sucessfully deleted");
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            string mydate   = "";
            string petname  = "";
            string memberid = "";
            string mydiary  = "";

            if (context.Request.HttpMethod == "POST")
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    switch (key)
                    {
                    case "mydate":
                        mydate = context.Request.Form[key];
                        break;

                    case "petname":
                        petname = context.Request.Form[key];
                        break;

                    case "memberid":
                        memberid = context.Request.Form[key];
                        break;

                    case "mymessage":
                        mydiary = context.Request.Form[key];
                        break;

                    default:
                        // You can use the default case.
                        break;
                    }
                }
            }

            Models.PetsDataContext db = new Models.PetsDataContext();
            DateTime myDateTime       = Convert.ToDateTime(mydate);

            var linqregisters = db.sp_InsertDiary(Convert.ToInt32(memberid), petname, mydiary, myDateTime);



            context.Response.ContentType = "text/plain";
            context.Response.Write("Diary entry sucessfully added");
        }
Exemple #3
0
        public void ProcessRequest(HttpContext context)
        {
            string nameofuser = "";
            string email      = "";
            string mymessage  = "";

            if (context.Request.HttpMethod == "POST")
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    switch (key)
                    {
                    case "nameofuser":
                        nameofuser = context.Request.Form[key];
                        break;

                    case "email":
                        email = context.Request.Form[key];
                        break;

                    case "mymessage":
                        mymessage = context.Request.Form[key];
                        break;

                    default:
                        // You can use the default case.
                        break;
                    }
                }
            }

            Models.PetsDataContext db = new Models.PetsDataContext();
            var linqregisters         = db.sp_InsertMessages(nameofuser, email, mymessage);

            context.Response.ContentType = "text/plain";
            context.Response.Write("message");
        }
Exemple #4
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            string petname         = "";
            string previouspetname = "";
            string color           = "";
            string breed           = "";
            string memberid        = "";
            string features        = "";
            string animalid        = "";

            if (context.Request.HttpMethod == "POST")
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    switch (key)
                    {
                    case "petname":
                        petname = context.Request.Form[key];
                        break;

                    case "previouspetname":
                        previouspetname = context.Request.Form[key];
                        break;

                    case "color":
                        color = context.Request.Form[key];
                        break;

                    case "breed":
                        breed = context.Request.Form[key];
                        break;

                    case "memberid":
                        memberid = context.Request.Form[key];
                        break;

                    case "animalid":
                        animalid = context.Request.Form[key];
                        break;

                    default:
                        string subkey = key.Substring(0, 7);
                        if (subkey == "feature")
                        {
                            features += "|F=" + context.Request.Form[key];
                        }
                        break;
                    }
                }
            }

            features = features.Substring(1);

            Models.PetsDataContext db = new Models.PetsDataContext();
            var updateanimal          = db.sp_InsertFeatures(color, 12, 12, 1, previouspetname, petname, "poodle", 1, Convert.ToInt32(memberid));
            var insertfeatures        = db.sp_InsertUniqueFeatures(Convert.ToInt32(animalid), features);

            context.Response.Redirect("StaticViews/Index.html#/PetsRegistered");
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            string username  = "";
            string password  = "";
            string email     = "";
            string mymessage = "";

            if (context.Request.HttpMethod == "POST")
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    switch (key)
                    {
                    case "user":
                        username = context.Request.Form[key];
                        break;

                    case "email":
                        email = context.Request.Form[key];
                        break;

                    case "mypasssword":
                        password = context.Request.Form[key];
                        break;

                    default:
                        // You can use the default case.
                        break;
                    }
                }
            }

            Models.PetsDataContext db = new Models.PetsDataContext();
            var linqregisters         = db.sp_registeruser(email, username, password);


            foreach (var linqregister in linqregisters)
            {
                int memberid = Convert.ToInt32(linqregister.memberid);
                if (memberid > 0)
                {
                    HttpCookie cookie1 = new HttpCookie("memberid");
                    cookie1.Value   = memberid.ToString();
                    cookie1.Expires = DateTime.Now.AddDays(30);
                    //cookie.Path = "/StaticViews";
                    context.Response.AppendCookie(cookie1);

                    HttpCookie cookie2 = new HttpCookie("yourname");
                    cookie2.Value   = username;
                    cookie2.Expires = DateTime.Now.AddDays(30);
                    //cookie.Path = "/StaticViews";
                    context.Response.AppendCookie(cookie2);
                    mymessage = linqregister.mymessage;
                }
                else
                {
                    mymessage = linqregister.mymessage;
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(mymessage);
        }
Exemple #6
0
        public void ProcessRequest(HttpContext context)
        {
            string username = "";
            string password = "";
            string message  = "1";

            if (context.Request.HttpMethod == "POST")
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    switch (key)
                    {
                    case "user":
                        username = context.Request.Form[key];
                        break;

                    case "password":
                        password = context.Request.Form[key];
                        break;

                    default:
                        // You can use the default case.
                        break;
                    }
                }
            }

            Models.PetsDataContext db = new Models.PetsDataContext();
            var linqregisters         = db.sp_login(username, password);

            bool checkifloggedin = false;

            foreach (var linqregister in linqregisters)
            {
                int        memberid = linqregister.memberid;
                HttpCookie cookie   = new HttpCookie("memberid");
                cookie.Value   = memberid.ToString();
                cookie.Expires = DateTime.Now.AddDays(30);
                //cookie.Path = "/StaticViews";
                context.Response.AppendCookie(cookie);
                checkifloggedin = true;
                message         = "1";
            }

            if (checkifloggedin == true)
            {
                HttpCookie cookie = new HttpCookie("yourname");
                cookie.Value   = username;
                cookie.Expires = DateTime.Now.AddDays(30);
                //cookie.Path = "/StaticViews";
                context.Response.AppendCookie(cookie);
            }
            else
            {
                // HttpCookie cookie = new HttpCookie("loginfailed");
                // cookie.Value = "true";
                // cookie.Expires = DateTime.Now.AddDays(1);
                //// cookie.Path = "/StaticViews";
                // context.Response.AppendCookie(cookie);
                message = "Please check your username and/or password";
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(message);
        }
Exemple #7
0
        public void ProcessRequest(HttpContext context)
        {
            string mymessage = "";

            if (context.Request.HttpMethod == "POST")
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    switch (key)
                    {
                    case "mymessage":
                        mymessage = context.Request.Form[key];
                        break;

                    default:
                        // You can use the default case.
                        break;
                    }
                }
            }

            Models.PetsDataContext db = new Models.PetsDataContext();
            var linqregisters         = db.sp_DoortjieMessages(mymessage);



            var myMessage = new SendGridMessage();

            // Add the message properties.
            myMessage.From = new MailAddress("*****@*****.**");

            // Add multiple addresses to the To field.
            List <String> recipients = new List <String>
            {
                @"Danie Rossouw <*****@*****.**>"
            };

            myMessage.AddTo(recipients);

            myMessage.Subject = "Mail from Doortjie";

            //Add the HTML and Text bodies


            myMessage.Html = mymessage;
            myMessage.Text = "Hello World plain text!";

            // Create network credentials to access your SendGrid account.
            var username = "******";
            var pswd     = "Lappies12";

            var credentials = new NetworkCredential(username, pswd);

            // Create an Web transport for sending email, using credentials...
            var transportWeb = new Web(credentials);

            // Send the email.
            try
            {
                //await transportWeb(myMessage);
                //Console.WriteLine("Sent!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR = " + ex.Message);
            }



            context.Response.ContentType = "text/plain";
            context.Response.Write("message");
        }