Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            StaffTimetable staffTimetable = db.StaffTimetables.Find(id);

            db.StaffTimetables.Remove(staffTimetable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "StaffTimetableId")] StaffTimetable staffTimetable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(staffTimetable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(staffTimetable));
 }
Exemplo n.º 3
0
        // GET: StaffTimetables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaffTimetable staffTimetable = db.StaffTimetables.Find(id);

            if (!staffTimetable.TimeTableAssigned)
            {
                var reg         = db.Classes.ToList();
                var assignedReg = reg.Where(x => x.AssignedTeacher == staffTimetable.AssignedTeacher).ToList();

                var staffSubs    = db.StaffSubjects.ToList();
                var assignedSubs = staffSubs.Where(x => x.AssignedTeacher == staffTimetable.AssignedTeacher).ToList();

                if (assignedSubs.Count > 0 || assignedReg.Count == 1)
                {
                    staffTimetable.HasAssignedClasses = true;
                }
                else
                {
                    staffTimetable.HasAssignedClasses = false;
                }

                if (assignedReg.Count == 1)
                {
                    staffTimetable.Registration = assignedReg.FirstOrDefault().ClassName;
                }

                if (assignedSubs.Count > 0)
                {
                    staffTimetable.TimeTableLayout = GetTimeTableLayout(assignedSubs);

                    staffTimetable.Monday    = staffTimetable.TimeTableLayout[0];
                    staffTimetable.Tuesday   = staffTimetable.TimeTableLayout[1];
                    staffTimetable.Wednesday = staffTimetable.TimeTableLayout[2];
                    staffTimetable.Thursday  = staffTimetable.TimeTableLayout[3];
                    staffTimetable.Friday    = staffTimetable.TimeTableLayout[4];
                }

                if (staffTimetable == null)
                {
                    return(HttpNotFound());
                }

                staffTimetable.TimeTableAssigned = true;
                db.SaveChanges();
            }

            return(View(staffTimetable));
        }
Exemplo n.º 4
0
        // GET: StaffTimetables/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaffTimetable staffTimetable = db.StaffTimetables.Find(id);

            if (staffTimetable == null)
            {
                return(HttpNotFound());
            }
            return(View(staffTimetable));
        }
        // GET: StaffTimetables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaffTimetable staffTimetable = db.StaffTimetables.Find(id);

            if (staffTimetable == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "Name", staffTimetable.StaffId);
            return(View(staffTimetable));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "StaffTimetableId")] StaffTimetable staffTimetable)
        {
            var reg         = db.Classes.ToList();
            var assignedReg = reg.Where(x => x.AssignedTeacher == staffTimetable.AssignedTeacher).ToList();

            var staffSubs    = db.StaffSubjects.ToList();
            var assignedSubs = staffSubs.Where(x => x.AssignedTeacher == staffTimetable.AssignedTeacher).ToList();

            if (assignedSubs.Count > 0 || assignedReg.Count == 1)
            {
                staffTimetable.HasAssignedClasses = true;
            }
            else
            {
                staffTimetable.HasAssignedClasses = false;
            }

            if (assignedReg.Count == 1)
            {
                staffTimetable.Registration = assignedReg.FirstOrDefault().ClassName;
            }

            if (assignedSubs.Count > 0)
            {
                staffTimetable.TimeTableLayout = GetTimeTableLayout(assignedSubs);

                staffTimetable.Monday    = staffTimetable.TimeTableLayout[0];
                staffTimetable.Tuesday   = staffTimetable.TimeTableLayout[1];
                staffTimetable.Wednesday = staffTimetable.TimeTableLayout[2];
                staffTimetable.Thursday  = staffTimetable.TimeTableLayout[3];
                staffTimetable.Friday    = staffTimetable.TimeTableLayout[4];
            }

            if (staffTimetable == null)
            {
                return(HttpNotFound());
            }

            staffTimetable.TimeTableAssigned = true;
            db.SaveChanges();


            return(View(staffTimetable));
        }
 public ActionResult Edit(StaffTimetable staffTimetable)
 {
     db.Entry(staffTimetable).State = EntityState.Modified;
     //db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(StaffTimetable staffTimetable)
 {
     db.StaffTimetables.Add(staffTimetable);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }