public ActionResult Create([Bind(Include = "HomeWorkId,Description,Deadline,ReqTime,LongDescription,CourseId")] Homework_174852 homework_174852)
 {
     ViewBag.HasCourse  = false;
     ViewBag.HomeWorkid = db.Homework_174852.Count();
     try
     {
         if (ModelState.IsValid)
         {
             db.Homework_174852.Add(homework_174852);
             Assignments_174852 new_assignment = new Assignments_174852();
             new_assignment.CourseId   = int.Parse(homework_174852.CourseId.ToString());
             new_assignment.HomeWorkId = homework_174852.HomeWorkId;
             new_assignment.TeacherId  = int.Parse(Session["TeacherId"].ToString());
             db.Assignments_174852.Add(new_assignment);
             db.SaveChanges();
             return(RedirectToAction("Index", "Admin"));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", "Cannot Insert");
         return(View(homework_174852));
     }
     ViewBag.HomeWorkId = new SelectList(db.Assignments_174852, "HomeWorkId", "HomeWorkId", homework_174852.HomeWorkId);
     return(View(homework_174852));
 }
        public ActionResult Create([Bind(Include = "TeacherId,CourseId")] Teaches_174852 teaches_174852)
        {
            if (ModelState.IsValid)
            {
                var res = db.Teaches_174852.Where(a => a.TeacherId == teaches_174852.TeacherId).FirstOrDefault();
                if (res == null)
                {
                    var c = db.Teaches_174852.Where(a => a.CourseId == teaches_174852.CourseId && a.TeacherId == teaches_174852.TeacherId).FirstOrDefault();
                    if (c == null)
                    {
                        db.Teaches_174852.Add(teaches_174852);
                        db.SaveChanges();
                        return(RedirectToAction("Index", "Admin"));
                    }
                    else
                    {
                        ViewBag.CourseId = new SelectList(db.Courses_174852, "CourseId", "CourseName");
                        ModelState.AddModelError("", "Cant Enroll, May Other Teacher or Yourself Already Teaching Same Course");
                        return(View());
                    }
                }
                else
                {
                    ViewBag.CourseId = new SelectList(db.Courses_174852, "CourseId", "CourseName");
                    ModelState.AddModelError("", "Cant Enroll, May You Already Teaching with Other Course or Others Teacher is teaching");
                    return(View());
                }
            }

            ViewBag.CourseId = new SelectList(db.Courses_174852, "CourseId", "CourseName", teaches_174852.CourseId);
            return(View(teaches_174852));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "TeacherId,Username,FirstName,LastName,Address,DOB,City,Password,MobileNumber,IsAdmin")] Teachers_174852 teachers_174852)
        {
            if (ModelState.IsValid)
            {
                db.Teachers_174852.Add(teachers_174852);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(teachers_174852));
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "StudentId,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday")] Planning_174852 planning_174852)
        {
            if (ModelState.IsValid)
            {
                db.Planning_174852.Add(planning_174852);
                db.SaveChanges();
                return(RedirectToAction("Index", "Student"));
            }

            ViewBag.StudentId = new SelectList(db.Student_174852, "StudentId", "Username", planning_174852.StudentId);
            return(View(planning_174852));
        }
 public ActionResult Update(Teachers_174852 t)
 {
     if (Session["TeacherId"] != null)
     {
         try
         {
             if (ModelState.IsValid)
             {
                 Teachers_174852 std = s.Teachers_174852.Where(x => x.TeacherId == t.TeacherId).FirstOrDefault();
                 if (std != null)
                 {
                     std.FirstName    = t.FirstName;
                     std.LastName     = t.LastName;
                     std.Address      = t.Address;
                     std.DOB          = t.DOB;
                     std.City         = t.City;
                     std.MobileNumber = t.MobileNumber;
                     s.SaveChanges();
                 }
                 return(RedirectToAction("Index", "Admin"));
             }
             return(RedirectToAction("Index", "Admin"));
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Index", "Admin"));
         }
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
Beispiel #6
0
 public ActionResult UpdateAssignmentRecord(int?TeacherId, int?HomeWorkId, string CourseName, string LongDescription, string ReqTime, string Description, string Deadline, int?CourseId, string StartDate, string EndDate)
 {
     TempData["CourseId"] = CourseId;
     try
     {
         var course   = db.Courses_174852.Where(a => a.CourseId == CourseId).FirstOrDefault();
         var Homework = db.Homework_174852.Where(a => a.HomeWorkId == HomeWorkId).FirstOrDefault();
         if (course != null)
         {
             course.StartDate = StartDate;
             course.EndDate   = (EndDate);
         }
         if (Homework != null)
         {
             Homework.LongDescription = LongDescription;
             Homework.ReqTime         = ReqTime;
             Homework.Description     = Description;
             Homework.Deadline        = Deadline;
         }
         db.SaveChanges();
         TempData["Status"] = true;
     }
     catch (Exception ex)
     {
         TempData["Status"] = false;
     }
     return(RedirectToAction("Index", "Assignment"));
 }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "CourseId,StudentId")] Enrollment_174852 enrollment_174852)
        {
            if (ModelState.IsValid)
            {
                var res = db.Enrollment_174852.Where(a => a.StudentId == enrollment_174852.StudentId).FirstOrDefault();
                if (res == null)
                {
                    db.Enrollment_174852.Add(enrollment_174852);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Student"));
                }
                else
                {
                    ModelState.AddModelError("", "May be You are Already Enrolled with One Course ");
                }
            }

            ViewBag.CourseId  = new SelectList(db.Courses_174852, "CourseId", "CourseName", enrollment_174852.CourseId);
            ViewBag.StudentId = new SelectList(db.Student_174852, "StudentId", "Username", enrollment_174852.StudentId);
            return(View(enrollment_174852));
        }
        public ActionResult Create([Bind(Include = "StudentId,Username,FName,LName,Address,DOB,City,Password,MobileNo")] Student_174852 student_174852)
        {
            if (Session["TeacherId"] != null)
            {
                if (ModelState.IsValid)
                {
                    db.Student_174852.Add(student_174852);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.StudentId = new SelectList(db.Planning_174852, "StudentId", "Monday", student_174852.StudentId);
                return(View(student_174852));
            }
            else
            {
                return(RedirectToAction("Login", "Admin"));
            }
        }
Beispiel #9
0
 public ActionResult Register(Student_174852 stud)
 {
     if (stud == null)
     {
         ViewBag.Message = "Please Enter Data";
     }
     if (ModelState.IsValid)
     {
         using (Training_20Feb_MumbaiEntity db = new Training_20Feb_MumbaiEntity())
         {
             db.Student_174852.Add(stud);
             db.SaveChanges();
             ViewBag.Message = "Successfully Registered.";
         }
         ModelState.Clear();
         ViewBag.Message = stud.FName + " " + stud.LName + "successfully registered";
     }
     return(View());
 }
 public ActionResult Register(Teachers_174852 teach)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Training_20Feb_MumbaiEntity db = new Training_20Feb_MumbaiEntity();
             db.Teachers_174852.Add(teach);
             db.SaveChanges();
             ModelState.Clear();
             ViewBag.Message = teach.FirstName + " " + teach.LastName + "successfully registered";
             return(RedirectToAction("Login"));
         }
         catch (Exception ex)
         {
             return(View(teach));
         }
     }
     return(View());
 }
Beispiel #11
0
        public ActionResult Update(string FName, string LName, string Address, DateTime DOB, string City, string MobileNo, int StudentId)
        {
            TempData.Clear();
            if (Session["StudentId"] != null)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        Student_174852 std = s.Student_174852.Where(x => x.StudentId == StudentId).FirstOrDefault();
                        if (std != null)
                        {
                            std.FName    = FName;
                            std.LName    = LName;
                            std.Address  = Address;
                            std.DOB      = DOB;
                            std.City     = City;
                            std.MobileNo = MobileNo;

                            s.SaveChanges();
                            TempData["Updated"] = true;
                            return(RedirectToAction("Index", "Student"));
                        }
                        else
                        {
                            TempData["Message"] = "You are not authorized.";
                            return(RedirectToAction("Login"));
                        }
                    }
                    return(View());
                }
                catch (Exception ex)
                {
                    TempData["message"] = "Some error occured";
                    return(View());
                }
            }
            return(View());
        }