コード例 #1
0
        public QuantityReceivedControllerTests()
        {
            mediator = A.Fake<IMediator>();
            controller = new QuantityReceivedController(mediator);

            A.CallTo(() =>
                mediator.SendAsync(A<GetMovementUnitsByMovementId>.That.Matches(r => r.Id == AnyGuid)))
                .Returns(ShipmentQuantityUnits.Kilograms);

            viewModel = new QuantityReceivedViewModel
            {
                Unit = ShipmentQuantityUnits.Kilograms,
                Quantity = "250"
            };
        }
コード例 #2
0
        public async Task<ActionResult> Index(Guid id, QuantityReceivedViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var tolerance =
                await mediator.SendAsync(new DoesQuantityReceivedExceedTolerance(id, Convert.ToDecimal(model.Quantity), model.Unit));

            TempData[DateReceivedKey] = model.DateReceived;
            TempData[UnitKey] = model.Unit;
            TempData[QuantityKey] = model.Quantity;

            if (tolerance == QuantityReceivedTolerance.AboveTolerance 
                || tolerance == QuantityReceivedTolerance.BelowTolerance)
            {
                TempData[ToleranceKey] = tolerance;
                return RedirectToAction("QuantityAbnormal");
            }

            return RedirectToAction("Index", "ReceiptComplete", new { id });
        }