Exemplo n.º 1
0
        public IActionResult AddLesson(ApiSettings apiSettings)
        {
            VMLesson lesson = ConvertJson.Deserialize <VMLesson>(apiSettings.Obj.ToString());

            _lessonService.AddLesson(lesson);
            return(Ok("Success"));
        }
        public IActionResult AddNewLesson([FromBody] dynamic newLessonParameters)
        {
            string dateTimeToParse = $"{newLessonParameters.lessonDate} {newLessonParameters.lessonTime}";

            if (!DateTime.TryParse(dateTimeToParse, out var lessonTime))
            {
                return(BadRequest("Невідомі дані про юзера"));
            }

            string roomName = newLessonParameters.lessonRoom;

            if (!int.TryParse(newLessonParameters.groupId.ToString(), out int groupId) && groupId < 1)
            {
                return(BadRequest("Невідомі дані про роль"));
            }

            var newLessonId = _lessonService.AddLesson(lessonTime, roomName, groupId);

            if (newLessonId < 1)
            {
                return(StatusCode(500));
            }

            return(Ok(newLessonId));
        }
        public IActionResult Index()
        {
            Lesson       l  = new Lesson();
            DaysOfLesson dl = new DaysOfLesson()
            {
                DayOfWeek = DayOfWeek.Monday,
                StartTime = "8.30",
                EndTime   = "12.29",
                AddedDate = DateTime.Now
            };
            List <LessonDay> ld = new List <LessonDay>()
            {
                new LessonDay {
                    Lesson       = l,
                    daysOfLesson = dl,
                    AddedDate    = DateTime.Now
                },
            };

            l.AddedDate         = DateTime.Now;
            l.LastAccessDate    = DateTime.Now.AddDays(10);
            l.EndDate           = DateTime.Now.AddDays(7);
            l.LessonCode        = "Mat101";
            l.LessonCredit      = 4;
            l.LessonCRN         = 12345;
            l.LessonDays        = ld;
            l.LessonDepartments = new List <LessonDepartment> {
                new LessonDepartment {
                    Department = new Department {
                        DepartmentName = "Feb", AddedDate = DateTime.Now,
                    }, Lesson = l
                }
            };
            l.LessonDescription = "İlk Deneme Buuuuu";
            l.LessonName        = "Matematik is The Best";
            l.TeacherId         = 1;
            l.UserLessons       = new List <UserLesson> {
                new UserLesson {
                    Lesson = l, UserId = 1, AddedDate = DateTime.Now
                }
            };
            var result = _lessonManager.AddLesson(l, 1);

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
            return(View());
        }
Exemplo n.º 4
0
        public IActionResult AddLesson(LessonDTO lessonDTO)
        {
            var teacherId = User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier)
                            .Select(c => c.Value).SingleOrDefault();
            var lesson = new Lesson
            {
                Name      = lessonDTO.Lesson,
                Period    = lessonDTO.Period,
                TeacherId = Convert.ToInt32(teacherId),
                Year      = lessonDTO.Year
            };

            _lessonService.AddLesson(lesson);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public async Task <string> AddLesson(LessonDto data)
        {
            await lessonService.AddLesson(data);

            return("Done!");
        }