Exemplo n.º 1
0
        public ActionResult UpdateUser(FormCollection form)
        {
            string userID = base.Request.Form["idPhoto"];

            ViewData["userID"] = userID;

            GetStories myGetStories = new GetStories();
            var        email        = myGetStories.GetMothersEmail(Convert.ToInt16(userID));

            //if (email =="")
            //{
            //    email = "Enter the email address";
            //}

            ViewData["email"] = email.ToString();
            string userName = base.Request.Form["userName"];
            //ViewData["userName"] = userName;

            MothersHelpersSpecificList myMothersHelpersSpecificList = new MothersHelpersSpecificList();

            myMothersHelpersSpecificList = myGetStories.GetMothersHelpersTypeSpecific(Convert.ToInt16(userID));



            DropdownModel model        = new DropdownModel();
            GetLookups    myGetLookups = new GetLookups();

            Story myStory = new Story();

            myStory.userName = userName;

            model = myGetLookups.GetMothersHelpersType();

            for (int i = 0; i < myMothersHelpersSpecificList.mothersHelpersSpecificLists.Count; i++)
            {
                var x = myMothersHelpersSpecificList.mothersHelpersSpecificLists[i].MothersHelpersType;


                foreach (SelectListItem s in model.items)
                {
                    if (s.Value == x)
                    {
                        s.Selected = true;
                    }
                }
            }


            ViewData["MothersHelpersTypeData"] = model.items;
            myStory.MothersHelpersTypeCombo    = model;



            return(View(myStory));
        }
        public response GetMothersEmail(int id)
        {
            GetStories myStories = new GetStories();

            return(myStories.GetMothersEmail(id));
        }
Exemplo n.º 3
0
        public ActionResult UploadPicture(FormCollection form)
        {
            System.Web.HttpPostedFileBase httpPostedFileBase = base.Request.Files["FileData"];
            string userID    = base.Request.Form["idPhoto"];
            string comments  = base.Request.Form["comments"];
            string filename1 = httpPostedFileBase.FileName;
            string text2     = base.Server.MapPath("~/images/upload/" + System.IO.Path.GetFileName(httpPostedFileBase.FileName));
            string value     = string.Empty;
            string text3     = System.IO.Path.GetExtension(httpPostedFileBase.FileName);

            text3 = text3.ToLower();
            GetStories myGetStories = new GetStories();

            ViewData["filename1"] = filename1;


            if (userID == "" || userID == null)
            {
                return(RedirectToAction("..\\Home"));
            }

            var email = myGetStories.GetMothersEmail(Convert.ToInt16(userID));


            if (text3 == ".jpg" || text3 == ".gif" || text3 == ".png" || text3 == ".mp3" || text3 == ".mp4")
            {
                if (httpPostedFileBase.ContentLength > 0)
                {
                    //string filename = base.Server.MapPath("/images/upload/" + text + text3);
                    string filename = base.Server.MapPath("/images/upload/" + filename1);
                    httpPostedFileBase.SaveAs(filename);

                    DynamicParameters dynamicParameters = new DynamicParameters();


                    dynamicParameters.Add("@Comments", comments, null, null, null);
                    dynamicParameters.Add("@fileName", filename1, null, null, null);

                    dynamicParameters.Add("@userID", System.Convert.ToInt16(userID), null, null, null);
                    ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["LocalStory"];
                    string connectionString = connectionStringSettings.ConnectionString;

                    using (System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString))
                    {
                        sqlConnection.Open();
                        const string storedProcedure = "dbo.InsertPicture";
                        var          values          = sqlConnection.Query <ReceipeTotalModel>(storedProcedure, dynamicParameters, commandType: CommandType.StoredProcedure);
                    }

                    using (MailMessage mail = new MailMessage())
                    {
                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add(email);
                        mail.Subject    = "Thank you for your work";
                        mail.Body       = "<h2>Thanks for uploading your file " + filename1 + " </h2>";
                        mail.IsBodyHtml = true;
                        //mail.Attachments.Add(new Attachment("C:\\file.zip"));

                        using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
                        {
                            smtp.UseDefaultCredentials = false;
                            smtp.EnableSsl             = true;
                            smtp.Credentials           = new NetworkCredential("*****@*****.**", "3Monkeys!");
                            smtp.Send(mail);
                        }
                    }


                    return(View());
                }
                else
                {
                    return(RedirectToAction("..\\Home"));
                }
            }

            return(View());
        }