コード例 #1
0
        public ActionResult AddStudent(Student Student)
        {
            if (Student.imagefile != null)
            {
                string filename   = Path.GetFileNameWithoutExtension(Student.imagefile.FileName);
                string extentsion = Path.GetExtension(Student.imagefile.FileName);
                filename = filename + DateTime.Now.ToString("yymmssfff") + extentsion;
                Student.Admissionimage = "~/images/" + filename;
                filename = Path.Combine(Server.MapPath("/images/"), filename);
                Student.imagefile.SaveAs(filename);
                Studentservice studentservice = new Studentservice();
                studentservice.savestudent(Student);
            }
            else

            {
                Student.Admissionimage = "download.png";



                Studentservice service = new Studentservice();
                service.savestudent(Student);
            }
            return(RedirectToAction("AssignClass", new { studentroll = Student.RollNo, id = Student.ID }));
        }
コード例 #2
0
        //public ActionResult downloadfile(int a)
        //{
        //    var getimage = studentservice.getbyid(a);
        //    Student student = new Student();
        //  var   stgimg = student.Admissionimage;
        //    string path = Server.MapPath("~stgimg");
        //    return View();

        //}
        public ActionResult EditStudent(int id)
        {
            Studentservice service = new Studentservice();
            var            Student = service.getbyid(id);

            TempData["imgpath"] = Student.Admissionimage;
            return(View(Student));
        }
コード例 #3
0
        public ActionResult EditStudent(Student Student)
        {
            if (Student.imagefile != null)
            {
                string filename   = Path.GetFileNameWithoutExtension(Student.imagefile.FileName);
                string extentsion = Path.GetExtension(Student.imagefile.FileName);
                filename = filename + DateTime.Now.ToString("yymmssfff") + extentsion;
                Student.Admissionimage = "~/images/" + filename;
                filename = Path.Combine(Server.MapPath("/images/"), filename);
                Student.imagefile.SaveAs(filename);
                Studentservice service = new Studentservice();
                service.updateStudent(Student);
            }
            else
            {
                Student.Admissionimage = TempData["imgpath"].ToString();

                Studentservice service = new Studentservice();
                service.updateStudent(Student);
            }
            return(RedirectToAction("Studentslist"));
        }