Beispiel #1
0
        public IActionResult GenerateTimetable([FromQuery] int hashCode, [FromBody] IEnumerable <CourseLecturerSettings> courseLecturerSettings)
        {
            bool courseUpdate = _timetableConfigService.UpdateUserCourseLecturerSettings(User.Identity.Name, hashCode, courseLecturerSettings);

            string conditions = _accountService.GetUser(User.Identity.Name).Conditions;

            TimetableData data = _timetableConfigService.GetTimetableDataByHashCode(User.Identity.Name, hashCode);

            if (!courseUpdate)
            {
                return(Ok(new { response = "failed to update course lecturer settings!" }));
            }
            if (data != null)
            {
                IEnumerable <Timetable> timetableList = _timetableGeneratorService.GenerateTimetableList(data, conditions);
                return(Ok(new { response = "success", data = timetableList }));
            }
            return(Ok(new { response = "not found" }));
        }