public async Task <IActionResult> GetData() { try { var user = await CurrentUser(); return(this.BuildDataTableForm <SchoolYearViewModel>(_sy.GetSchoolYears(user.School.Id))); } catch (Exception ex) { // Info Console.Write(ex); return(null); } }
public async Task <IActionResult> NewData(SchoolLevelViewModel data) { var user = await CurrentUser(); if (Validate()) { var result = await _lvl.AddSchoolLevel(data); if (result.Succeeded) { return(RedirectToAction("Success", new { message = "Creating new level " + data.Name + " succeeded!" })); } else { AddPageAlerts(PageAlertType.Warning, result.Error.Description); } } AddPageHeader("Levels"); AddBreadcrumb("Levels", "/level"); AddBreadcrumb("[New]", ""); var model = new SchoolLevelViewModel(); model.SchoolYearsSelections = _sy.GetSchoolYears(user.School.Id) .Select(o => new SelectListItem() { Text = o.Name, Value = o.Id.ToString() }) .ToList(); return(View(model)); }