Esempio n. 1
0
        public async Task <IActionResult> Create(ClassCreateRequestModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(Create)));
            }

            await this.classService.Create(model);

            return(await Index());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create()
        {
            var schoolId = await this.userService.GetSchoolIdForUser(UserId);

            var subjects = await this.subjectService.GetAll(schoolId);

            var model = new ClassCreateRequestModel
            {
                Subjects = subjects,
                SchoolId = schoolId
            };

            return(View(nameof(Create), model));
        }
Esempio n. 3
0
        public async Task Create(ClassCreateRequestModel model)
        {
            if (model == null)
            {
                throw new Exception("Model cannot be null");
            }

            var subjects = await this.data.Subjects.Where(s => model.SubjectIds.Contains(s.Id)).ToListAsync();

            var @class = new Class
            {
                Name     = model.Name,
                Group    = model.Group,
                SchoolId = model.SchoolId,
                Subject  = subjects
            };

            this.data.Classes.Add(@class);

            await this.data.SaveChangesAsync();
        }
Esempio n. 4
0
 public Response <ClassModel> CreateClass(ClassCreateRequestModel model)
 {
     return(_studentHandler.CreateClass(model));
 }