protected virtual void SaveOrUpdate(ExamSheetViewModel model) { var businessModel = CreateModel(model); ExamSheetManager.Save(businessModel); //TODO: generate word doc and save it }
public IActionResult CreateExamSheet() { var faculty = GetDeaneryFaculty(User.Identity.Name); var model = new ExamSheetViewModel() { Id = Guid.NewGuid().ToString(), //OpenDate = DateTime.Now, Faculty = CreateFacultyViewModel(faculty) }; InitSelectItems(model.Faculty.Id); return(View(model)); }
protected virtual ExamSheetModel CreateModel(ExamSheetViewModel viewModel) { return(new ExamSheetModel() { Id = viewModel.Id, State = (Business.ExamSheet.ExamSheetState)viewModel.State, //OpenDate = viewModel.OpenDate, TeacherId = viewModel.TeacherId, FacultyId = viewModel.Faculty.Id, GroupId = viewModel.GroupId, SubjectId = viewModel.SubjectId, Semester = viewModel.Semester, Year = viewModel.Year, CloseDate = viewModel.CloseDate }); }
public IActionResult Edit(ExamSheetViewModel model) { if (!ModelState.IsValid) { InitSelectItems(model.Faculty.Id); return(View(model)); } var examSheet = ExamSheetManager.Get(model.GroupId, model.TeacherId, model.SubjectId, model.Year, model.Semester); if (examSheet != null && examSheet.Id != model.Id) { ModelState.AddModelError(string.Empty, "Така відомість вже існує!"); InitSelectItems(model.Faculty.Id); return(View(model)); } SaveOrUpdate(model); return(RedirectToAction("Index", "Home")); }