public ActionResult AddHoursInDay([Bind(Include = "Id,Topic,AmountOfTeachingHours,TimeAllocationId,RemainingTime,url")] AddCourseInDayViewModel addCourseInDayViewModel)
        {
            var timeAllocationInstance = db.TimeOfCourse.Find(addCourseInDayViewModel.TimeAllocationId);

            var course = db.Courses.Find(addCourseInDayViewModel.Id);

            if (course != null)
            {
                CourseWithTimeAllocation courseWithTimeAllocation = new CourseWithTimeAllocation()
                {
                    CourseId = addCourseInDayViewModel.Id, CourseName = course.CourseName, AmountOfTeachingHours = addCourseInDayViewModel.AmountOfTeachingHours, ProgramId = course.ProgramId, TimeAllocationHelperId = addCourseInDayViewModel.TimeAllocationId, Topic = addCourseInDayViewModel.Topic
                };
                timeAllocationInstance.RemainingTime -= addCourseInDayViewModel.RemainingTime;
                db.CourseWithTimeAllocations.Add(courseWithTimeAllocation);
                db.SaveChanges();
                var instanceOfCourseDataHelper = db.ScheduleHelperContextPerCourse.Where(x => x.courseId == course.Id).FirstOrDefault();

                instanceOfCourseDataHelper.OverallTotalHours -= addCourseInDayViewModel.AmountOfTeachingHours;

                instanceOfCourseDataHelper.NoOfTeachingDays += 1;
                if (course.EndDate < timeAllocationInstance.Date)
                {
                    course.EndDate = timeAllocationInstance.Date;
                }
                db.SaveChanges();

                string path = addCourseInDayViewModel.url;
                path += "#" + timeAllocationInstance.Date.ToString("MMMM") + "-" + timeAllocationInstance.Date.Year;
                return(Redirect(path));
            }
            ViewBag.Id = new SelectList(db.Courses.ToList(), "Id", "CourseName");

            return(View());
        }
        public ActionResult AddHoursInDay(int?TimeAllocationHelperId, string url = "")
        {
            var timeAllocationInstance = db.TimeOfCourse.Find(TimeAllocationHelperId);

            var courses = db.Courses.Where(x => x.ProgramId == timeAllocationInstance.ProgramId).ToList();

            ViewBag.Id = new SelectList(courses, "Id", "CourseName");
            AddCourseInDayViewModel addCourseInDayViewModel = new AddCourseInDayViewModel()
            {
                RemainingTime = timeAllocationInstance.RemainingTime, TimeAllocationId = timeAllocationInstance.Id, url = url, AmountOfTeachingHours = 0, Topic = ""
            };

            return(View(addCourseInDayViewModel));
        }