Esempio n. 1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var validationResults = new List <ValidationResult>();
            var instance          = validationContext.ObjectInstance as HomeViewModel;

            if (instance != null)
            {
                if (!instance.SelectedId.HasValue)
                {
                    validationResults.Add(
                        new ValidationResult($"Select an {FacilityType.ToDisplayString()} to perform activities"));
                }
            }

            ModelValidated = true;
            return(validationResults);
        }
Esempio n. 2
0
        public virtual async Task <ActionResult> Index(Guid organisationId, FacilityType facilityType)
        {
            using (var client = apiClient())
            {
                var allAatfsAndAes = await client.SendAsync(User.GetAccessToken(), new GetAatfByOrganisation(organisationId));

                var model = mapper.Map(new AatfDataToHomeViewModelMapTransfer()
                {
                    AatfList = allAatfsAndAes, OrganisationId = organisationId, FacilityType = facilityType
                });

                if (model.AatfList.Count == 1)
                {
                    return(RedirectToAction("Index", "ContactDetails", new { organisationId, aatfId = model.AatfList[0].Id, facilityType }));
                }

                await SetBreadcrumb(model.OrganisationId, string.Format(AatfAction.ManageAatfContactDetails, facilityType.ToDisplayString()));

                return(View(model));
            }
        }