// GET: DisciplineStages/Create public IActionResult Create() { var model = new DisciplineStageCreateViewModel() { EmployeeList = _disciplineStagesRepository.EmployeeList() }; return(View(model)); }
public async Task <IActionResult> Create([Bind("VerbalWarning,Written,OneDay,ThreeDay,FiveDay,TwoWeek,ThirtyDay,EmployeeNumber")] DisciplineStageCreateViewModel disciplineStage) { try { if (ModelState.IsValid) { var disciplineStagedb = new DisciplineStage() { EmployeeNumber = disciplineStage.EmployeeNumber, VerbalWarning = disciplineStage.VerbalWarning, OneDay = disciplineStage.OneDay, ThreeDay = disciplineStage.ThreeDay, FiveDay = disciplineStage.FiveDay, TwoWeek = disciplineStage.TwoWeek, ThirtyDay = disciplineStage.ThirtyDay, Written = disciplineStage.Written }; await _disciplineStagesRepository.CreateDiscipline(disciplineStagedb); return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "Unable to save changes. " + "Enter a valid Employee Number "); } } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(disciplineStage)); }