public async Task<ActionResult> SaveDataContact(ContactModel f)
        {

            if (ModelState.IsValid)
            {
                D.Open();
                bool check = D.DataSearch("SELECT * FROM table_form WHERE Email = '" + f.Email + "' ");
                D.Close();
                if (check == false)
                {
                    if (Request.Files.Count > 0)
                    {
                        var file = Request.Files[0];

                        if (file != null && file.ContentLength > 0)
                        {
                           // αποθηκεύουμε το αρχείο στο σημείο που θέλουμε και πέρχουμε το όνομα του αρχείου για να το αποθηκεύσουμε στην συνεχεια στην βδ
                            f.nameofcv = Path.GetFileName(file.FileName);
                            var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), f.nameofcv);
                            file.SaveAs(path);


                            D.Open();
                            int i = D.DataInsert("INSERT INTO table_form(First_Name,Last_Name,Age,Email,Comments,File_Name,Job_Title) VALUES ('" + f.FirstName + "','" + f.LastName + "','" + f.Age + "','" + f.Email + "','" + f.Comments + "','" + file.FileName + "','" + f.nameofjob + "')");
                            if (i > 0)
                            {
                                ModelState.AddModelError("Success", "Save Success");
                            }
                            else
                            {
                                ModelState.AddModelError("Error", "Save Error");
                            }

                            TempData["notice"] = 1;

                            await SendEmail(f.Email, f.nameofjob,f.LastName);
                            
                        }

                    }

                    D.Close();
                }
                else
                {

                    TempData["check_db"] = 1;
                }
            }



            return RedirectToAction("ContactForm", "Contact");
        }
 public ActionResult DeleteApplier(ContactModel f)
 {
     string fullPath = Request.MapPath("~/App_Data/uploads/" + f.nameofcv);
     System.IO.File.Delete(fullPath);
     D.Open();
     int i = D.DataDelete("DELETE FROM table_form WHERE  Email= '" + f.Email + "' ");
     D.Close();
      if (i > 0)
     {ModelState.AddModelError("Success", "Save Success");}
     else
     {ModelState.AddModelError("Error", "Save Error");}
     return RedirectToAction("Jobs", "Dashboard");
 }
        public ActionResult SaveDataContact(ContactModel f)
        {
            if (ModelState.IsValid)
            {
                D.Open();
                int i=D.DataInsert("INSERT INTO table_cont(Name,Email,Comments) VALUES ('" + f.Name + "','" + f.Email + "','" + f.Comments + "')");
                if (i>0)
                {
                    ModelState.AddModelError("Success","Save Success");
                }
                else
                {
                    ModelState.AddModelError("Error", "Save Error");
                }

                D.Close();
            }
            return RedirectToAction("Index", "Home");
        }
 public ActionResult Jobs()
 {
     ContactModel p = new ContactModel();
     List<ContactModel> Li = new List<ContactModel>();
     Li = p.JobDisplay();
     ViewData["JobDisplay"] = Li;
     return View();
 }
Exemple #5
0
        public List<ContactModel> JobDisplay()
        {
            SqlConnection con = new SqlConnection(constr);
            con.Open();

            using (con)
            {
                SqlCommand cmd = new SqlCommand("Select * from table_form ", con);
                SqlDataReader rd = cmd.ExecuteReader();

                while (rd.Read())
                {

                    p = new ContactModel();
                    p.FirstName = Convert.ToString(rd.GetSqlValue(1));
                    p.LastName = Convert.ToString(rd.GetSqlValue(2));
                    p.Age = (int)rd["Age"];
                    p.Email = Convert.ToString(rd.GetSqlValue(4));
                    p.Comments = Convert.ToString(rd.GetSqlValue(5));
                    p.nameofcv = Convert.ToString(rd.GetSqlValue(6));
                    p.nameofjob = Convert.ToString(rd.GetSqlValue(7));
                    JobList.Add(p);

                }
            }

            return JobList;
        }