Exemple #1
0
        public async Task <IActionResult> Post([FromBody] LessonView item)
        {
            //Console.WriteLine("Запрос добавления урока: " + item.lesson.Name + " п " + item.nameClass);
            if (ModelState.IsValid)
            {
                Class bufferClass = await _timeTable.GetClassAsync(item.nameClass);

                Teacher bufferTeacher = await _timeTable.GetTeacherAsync(item.nameTeacher);

                Lesson buffer = new Lesson
                {
                    Name    = item.lesson.Name,
                    Day     = item.lesson.Day,
                    Number  = item.lesson.Number,
                    Class   = bufferClass,
                    Teacher = bufferTeacher
                };
                await _timeTable.AddLessonAsync(buffer);

                return(Json(buffer));
            }
            return(BadRequest("Ошибка валидации!"));
        }