public async Task <IActionResult> Create(ClassCreateRequestModel model) { if (!ModelState.IsValid) { return(View(nameof(Create))); } await this.classService.Create(model); return(await Index()); }
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)); }
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(); }
public Response <ClassModel> CreateClass(ClassCreateRequestModel model) { return(_studentHandler.CreateClass(model)); }