Esempio n. 1
0
 public ActionResult Editcour(Cours c)
 {
     if (ModelState.IsValid)
     {
         db.Entry(c).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("getAllCourses"));
     }
     else
     {
         ViewBag.depts = new SelectList(db.Departments.ToList(), "dept_id", "DeptName", c.Department.DeptName);
         ViewBag.profs = new SelectList(db.Professors.ToList(), "prof_id", "PersonalName", c.Professor.PersonalName);
         return(View(c));
     }
 }
Esempio n. 2
0
        public ActionResult EditProf(Student std, HttpPostedFileBase Poster)
        {
            var ad = db.Students.Any(ww => ww.UserName == std.UserName && ww.Student_Code != std.Student_Code);

            if (ad)
            {
                ViewBag.error    = "This UserName Is Already Exist!!";
                ViewBag.DeptList = new SelectList(db.Departments.ToList(), "Dept_Id", "DeptName", std.Dept_Id);
                return(View("Editprofile", std));
            }


            if (ModelState.IsValid)
            {
                std.Gender     = Session["gender"].ToString();
                std.Admin_Id   = int.Parse(Session["admin_id"].ToString());
                std.Attendence = int.Parse(Session["attendance"].ToString());
                std.Visible    = bool.Parse(Session["visible"].ToString());
                std.BirthDate  = DateTime.Parse(Session["bd"].ToString());
                std.Type       = Session["type"].ToString();

                if (Poster != null && Poster.ContentLength > 0)
                {
                    Poster.SaveAs(Server.MapPath($"~/Images/{Poster.FileName}"));
                    std.Photo = Poster.FileName;
                }
                if (std.Photo == null)
                {
                    std.Photo = "user2.png";
                }

                db.Entry(std).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction($"StudentCourses/{std.Student_Code}"));
            }
            ViewBag.DeptList = new SelectList(db.Departments.ToList(), "Dept_Id", "DeptName", std.Dept_Id);
            return(View("Editprofile", std));
        }
Esempio n. 3
0
        public ActionResult editLec(Lecture l)
        {
            if (l.File != null)
            {
                String FileExt = Path.GetExtension(l.File.FileName).ToUpper();
                if (FileExt == ".PDF")
                {
                    if (l.File.ContentLength <= 0)
                    {
                        return(null);
                    }

                    Byte[] data = new byte[l.File.ContentLength];
                    l.File.InputStream.Read(data, 0, l.File.ContentLength);
                    l.PDF = l.File.FileName;
                    var path = Path.Combine(Server.MapPath("~/pdfs"), l.PDF);
                    l.File.SaveAs(path);
                    l.FileContent = data;
                }
            }
            if (l.Vid != null)
            {
                String FileExtvid = Path.GetExtension(l.Vid.FileName).ToUpper();

                if (FileExtvid == ".MP4")
                {
                    if (l.Vid.ContentLength <= 0)
                    {
                        return(null);
                    }
                    var fileName = Path.GetFileName(l.Vid.FileName);
                    if (fileName == null)
                    {
                        return(null);
                    }
                    var path = Path.Combine(Server.MapPath("~/Videos"), fileName);
                    l.Vid.SaveAs(path);
                    l.Video = l.Vid.FileName;
                }
            }
            if (l.Aud != null)
            {
                String FileExtaud = Path.GetExtension(l.Aud.FileName).ToUpper();

                if (FileExtaud == ".MP3")
                {
                    if (l.Aud.FileName == null)
                    {
                        return(null);
                    }
                    var fileName = Path.GetFileName(l.Aud.FileName);
                    if (fileName == null)
                    {
                        return(null);
                    }
                    var path = Path.Combine(Server.MapPath("~/Audios"), fileName);
                    l.Aud.SaveAs(path);
                    l.Audio = l.Aud.FileName;
                }
            }
            l.Course_Code     = Session["course_id"].ToString();
            db.Entry(l).State = EntityState.Modified;
            var x = db.SaveChanges();

            if (x == 1)
            {
                return(RedirectToAction("/CourseLectures/", new { id = l.Course_Code }));
            }

            return(View("EditLecture", l));
        }