use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsController method deleteConfirmation.
@GetMapping("delete/{id}")
public String deleteConfirmation(@PathVariable("id") Integer id, Model model) {
final SubjectDto subjectDto = new SubjectDto();
final SubjectModelInterface subjectModel = getSubjectModel(id);
subjectDto.map(subjectModel);
model.addAttribute("subject", subjectDto);
return "subjects/delete";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsController method delete.
@PostMapping("delete/{id}")
public String delete(@PathVariable("id") Integer subjectId, SubjectDto subjectDto, BindingResult bindingResult, Model model) {
final SubjectModelInterface subjectModel = getSubjectModel(subjectId, subjectsOptionsBuilder.forDelete());
subjectsService.delete(subjectModel, subjectsOptionsBuilder.forDelete());
return "redirect:/personal/subjects/list";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsController method create.
@PostMapping("create")
public String create(@Valid @NotNull SubjectDto subject, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
model.addAttribute("methodType", "create");
model.addAttribute("subject", subject);
model.addAttribute("errors", bindingResult);
return "subjects/form";
}
final SubjectModelInterface subjectModel = new SubjectModel();
subject.mapInto(subjectModel);
subjectModel.setUser(this.getCurrentUserModel());
subjectsService.save(subjectModel);
final IssueStandardModelInterface issueStandardModel = new IssueStandardModel();
issueStandardModel.setSubject(new SubjectModelEmpty(subjectModel.getId()));
issueStandardsService.save(issueStandardModel);
return "redirect:/personal/subjects/list";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsController method update.
@PostMapping("update/{id}")
public String update(@PathVariable("id") Integer subjectId, @Valid @NotNull SubjectDto subject, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
model.addAttribute("methodType", "update");
model.addAttribute("subject", subject);
model.addAttribute("errors", bindingResult);
return "subjects/form";
}
final SubjectModelInterface subjectModel = getSubjectModel(subjectId);
subject.mapInto(subjectModel);
subjectsService.save(subjectModel);
return "redirect:/personal/subjects/list";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsController method getCurrentSubjectModel.
private SubjectModelInterface getCurrentSubjectModel(Integer subjectId, boolean withTopics) {
final SubjectsOptionsInterface subjectsOptions = this.subjectsOptionsBuilder.forAuth();
final SubjectModelInterface subjectModel = subjectsService.find(subjectId, subjectsOptions);
if (withTopics) {
final List<TopicModelInterface> topics = this.topicsService.findBySubject(subjectModel);
subjectModel.setTopics(topics);
}
checkModel(subjectModel);
return subjectModel;
}
Aggregations