public async Task <ActionResult> Edit(EditScheduledClassViewModel viewModel) { if (ModelState.IsValid) { var isSuccess = await _scheduledClassService.UpdateScheduledClass(viewModel); if (isSuccess) { _logger.Info($"Scheduled class ID {viewModel.Id} was edited successfully with {viewModel.InstructorName} assigned as instructor"); return(RedirectToAction("Index")); } } return(View(viewModel)); }
public async Task <bool> UpdateScheduledClass(EditScheduledClassViewModel viewModel) { var dto = new ScheduledClassDto() { Id = viewModel.Id, ClassStartTime = viewModel.ClassStartTime, ClassTypeName = viewModel.ClassTypeName, InstructorName = viewModel.InstructorName, IsCancelled = viewModel.IsCancelled }; var isSuccess = _scheduledClassWriter.UpdateScheduledClass(dto); return(await Task.FromResult(isSuccess)); }
public async Task <ActionResult> Edit(string id) { if (id == null) { _logger.Trace("No parameters passed for Edit"); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var instructors = await _scheduledClassService.GetAllInstructorNames(); ScheduledClassDto dto = await _scheduledClassService.GetScheduledClass(id); if (dto == null) { _logger.Info($"Parameter {id} was passed for Edit but did not return a result"); return(HttpNotFound()); } EditScheduledClassViewModel viewModel = new EditScheduledClassViewModel(dto, instructors); return(View(viewModel)); }