public void CanEnsureRecordingCreationIsValid() { Recording recordingFromForm = new Recording(); ViewResult result = controller.Create(recordingFromForm).AssertViewRendered(); result.ViewData.Model.ShouldNotBeNull(); result.ViewData.Model.ShouldBeOfType(typeof(RecordingFormViewModel)); }
public void CanCompareRecordings() { var instance = new Recording { Date = DateTime.Parse("01/27/2010"), Url = "http://www.viddler.com/explore/virtualaltnet/videos/1" }; var instanceToCompareTo = new Recording { Date = DateTime.Parse("01/27/2010"), Url = "http://www.viddler.com/explore/virtualaltnet/videos/1" }; instance.ShouldEqual(instanceToCompareTo); }
public ActionResult Create(Recording recording) { if (ViewData.ModelState.IsValid) { ActionConfirmation saveOrUpdateConfirmation = recordingManagementService.SaveOrUpdate(recording); if (saveOrUpdateConfirmation.WasSuccessful) { TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = saveOrUpdateConfirmation.Message; return RedirectToAction("Index"); } } RecordingFormViewModel viewModel = recordingManagementService.CreateFormViewModelFor(recording); return View(viewModel); }
public RecordingFormViewModel CreateFormViewModelFor(Recording recording) { RecordingFormViewModel viewModel = CreateFormViewModel(); viewModel.Recording = recording; return viewModel; }
private void TransferFormValuesTo(Recording recordingToUpdate, Recording recordingFromForm) { recordingToUpdate.Title = recordingFromForm.Title; recordingToUpdate.Url = recordingFromForm.Url; recordingToUpdate.Date = recordingFromForm.Date; recordingToUpdate.Duration = recordingFromForm.Duration; recordingToUpdate.Speaker = recordingFromForm.Speaker; recordingToUpdate.Group = recordingFromForm.Group; recordingToUpdate.LiveMeetingUrl = recordingFromForm.LiveMeetingUrl; recordingToUpdate.Description = recordingFromForm.Description; }
public ActionConfirmation UpdateWith(Recording recordingFromForm) { Recording recordingToUpdate = recordingRepository.Get(recordingFromForm.Id); TransferFormValuesTo(recordingToUpdate, recordingFromForm); if (recordingToUpdate.IsValid()) { ActionConfirmation updateConfirmation = ActionConfirmation.CreateSuccessConfirmation( "The recording was successfully updated."); updateConfirmation.Value = recordingToUpdate; return updateConfirmation; } else { recordingRepository.DbContext.RollbackTransaction(); return ActionConfirmation.CreateFailureConfirmation( "The group could not be saved due to missing or invalid information."); } }
public ActionConfirmation SaveOrUpdate(Recording recording) { if (recording.IsValid()) { recordingRepository.SaveOrUpdate(recording); ActionConfirmation saveOrUpdateConfirmation = ActionConfirmation.CreateSuccessConfirmation( "The recording was successfully saved."); saveOrUpdateConfirmation.Value = recording; return saveOrUpdateConfirmation; } else { recordingRepository.DbContext.RollbackTransaction(); return ActionConfirmation.CreateFailureConfirmation( "The recording could not be saved due to missing or invalid information."); } }
/// <summary> /// Creates a valid, transient Recording; typical of something retrieved back from a form submission /// </summary> private Recording CreateTransientRecording() { Recording recording = new Recording() { Date = DateTime.Parse("01/27/2010"), Url = "http://www.viddler.com/explore/virtualaltnet/videos/1", LiveMeetingUrl = "http://www.viddler.com/explore/virtualaltnet/videos/1" }; return recording; }