public async Task <ActionResult> Index(Guid id, bool?backToOverview = null) { var physicalCharacteristics = CheckBoxCollectionViewModel.CreateFromEnum <PhysicalCharacteristicType>(); physicalCharacteristics.ShowEnumValue = true; //We need to exclude 'other' as this will be handled separately physicalCharacteristics.PossibleValues = physicalCharacteristics.PossibleValues.Where( p => (PhysicalCharacteristicType)Convert.ToInt32(p.Value) != PhysicalCharacteristicType.Other) .ToList(); var model = new PhysicalCharacteristicsViewModel { PhysicalCharacteristics = physicalCharacteristics, NotificationId = id }; var physicalCharacteristicsData = await mediator.SendAsync(new GetPhysicalCharacteristics(id)); if (physicalCharacteristicsData != null) { model.PhysicalCharacteristics.SetSelectedValues(physicalCharacteristicsData.PhysicalCharacteristics); if (!string.IsNullOrWhiteSpace(physicalCharacteristicsData.OtherDescription)) { model.OtherSelected = true; model.OtherDescription = physicalCharacteristicsData.OtherDescription; } } return(View(model)); }
public async Task Create_ExceedsShipmentsRemaining_ReturnsError() { movementId[0] = Guid.NewGuid(); var remainingshipment = new RemainingShipmentsData { ShipmentsRemaining = 100, ActiveLoadsPermitted = 20, ActiveLoadsRemainingByDate = 20 }; var model = new CreateMovementsViewModel { Day = 6, Month = 2, Year = 2019, Quantity = "1", NumberToCreate = remainingshipment.ShipmentsRemaining + 1, PackagingTypes = CheckBoxCollectionViewModel.CreateFromEnum <PackagingType>() }; model.PackagingTypes.PossibleValues.First(y => y.Value == "1").Selected = true; model.Units = ShipmentQuantityUnits.Kilograms; A.CallTo( () => mediator.SendAsync(A <GetRemainingShipments> .That.Matches(p => p.NotificationId == notificationId))) .Returns(remainingshipment); var result = await controller.Index(notificationId, model) as ViewResult; Assert.NotNull(result); Assert.False(result.ViewData.ModelState.IsValid); Assert.True(result.ViewData.ModelState.Keys.Any(k => k == NumberToCreateDisplayName)); }
private PackagingTypesViewModel CreateValidPackagingTypesViewModel() { var packagingTypes = CheckBoxCollectionViewModel.CreateFromEnum <PackagingType>(); var selectedValues = new[] { 1, 2 }; packagingTypes.SetSelectedValues(selectedValues); return(new PackagingTypesViewModel() { PackagingTypes = packagingTypes, NotificationId = notificationId }); }
public ActionResult ColumnSelection( FOIReportDates dateType, DateTime from, DateTime to, FOIReportTextFields?textFieldType, TextFieldOperator?operatorType, string textSearch) { var foiOutputColumns = CheckBoxCollectionViewModel.CreateFromEnum <FOIOutputColumns>(); var model = new ColumnSelectionViewModel(dateType, from, to, textFieldType, operatorType, textSearch, foiOutputColumns); return(View(model)); }
public async Task Create_ReturnsWhoAreyourCarrier() { var packagingTypes = CheckBoxCollectionViewModel.CreateFromEnum <PackagingType>(); movementId[0] = new Guid("AF1839A1-DA40-430B-9DFE-D79194175DFD"); var remainingshipment = new RemainingShipmentsData { ShipmentsRemaining = 400, ActiveLoadsPermitted = 300, ActiveLoadsRemainingByDate = 100 }; var model = new CreateMovementsViewModel { Day = 6, Month = 2, Year = 2019, Quantity = "1", NumberToCreate = 1, PackagingTypes = packagingTypes }; model.PackagingTypes.PossibleValues.First(y => y.Value == "1").Selected = true; model.Units = ShipmentQuantityUnits.Kilograms; A.CallTo( () => mediator.SendAsync(A <GetRemainingShipments> .That.Matches(p => p.NotificationId == notificationId))) .Returns(remainingshipment); A.CallTo( () => mediator.SendAsync(A <GetWorkingDaysUntil> .That.Matches(p => p.NotificationId == notificationId))) .Returns(6); A.CallTo(() => mediator.SendAsync(A <CreateMovements> .That.Matches(p => p.NotificationId == notificationId))) .Returns(movementId); var result = await controller.Index(notificationId, model) as RedirectToRouteResult; Assert.NotNull(result); Assert.Equal("WhoAreYourCarriers", result.RouteValues["action"]); }