public async Task Create(SubjectCreateRequestModel model) { var subjectModel = new Subject { Name = model.Name, SchoolId = model.SchoolId.Value }; this.data.Add(subjectModel); await this.data.SaveChangesAsync(); }
public async Task <IActionResult> Create(SubjectCreateRequestModel model) { if (!ModelState.IsValid) { return(View(nameof(Create))); } var schoolId = await this.userService.GetSchoolIdForUser(UserId); if (!model.SchoolId.HasValue) { model.SchoolId = schoolId; } await this.subjectService.Create(model); return(await AllSubjects()); }