public ActionResult Create(Request request) { try { if (ViewData.ModelState.IsValid) { request.LastUpdateTimeStamp = DateTime.Now; request.LastUpdateUser = GetCurrentUser().Id; ActionConfirmation saveOrUpdateConfirmation = _requestManagementService.SaveOrUpdate(request); if (saveOrUpdateConfirmation.WasSuccessful) { TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = saveOrUpdateConfirmation.Message; //return RedirectToAction("Index"); return(RedirectToAction("Search")); } } else { request = null; } } catch (PreconditionException pce) { TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = pce.Message; } RequestFormViewModel viewModel = _requestManagementService.CreateFormViewModelFor(request); return(View(viewModel)); }
public void CanCreateFormViewModelForRequest() { // Establish Context var viewModelToExpect = new RequestFormViewModel(); Request request = RequestInstanceFactory.CreateValidTransientRequest(); _requestRepository.Expect(r => r.Get(1)) .Return(request); // Act RequestFormViewModel viewModelRetrieved = _requestManagementService.CreateFormViewModelFor(1); // Assert viewModelRetrieved.ShouldNotBeNull(); viewModelRetrieved.Request.ShouldNotBeNull(); viewModelRetrieved.Request.ShouldEqual(request); }