Exemplo n.º 1
0
        public void CanSaveOrUpdateValidRequest()
        {
            // Establish Context
            Request validRequest =
                RequestInstanceFactory.CreateValidTransientRequest();

            WrmsSystem systemToExpect = WrmsSystemInstanceFactory.CreateValidTransientWrmsSystem();

            _wrmsSystemManagementService.Expect(r => r.Get(13))
            .Return(systemToExpect);

            _requestEstimateManagementService.Expect(
                r =>
                r.SaveOrUpdate(new RequestEstimate
            {
                RequestId = validRequest.Id, EstimatedHours = validRequest.EstimatedHours
            })).Return(
                ActionConfirmation.CreateSuccessConfirmation(""));

            // Act
            ActionConfirmation confirmation =
                _requestManagementService.SaveOrUpdate(validRequest);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(validRequest);
        }
Exemplo n.º 2
0
        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));
        }