Пример #1
0
        public async Task <Result <List <SubCountyLookup> > > Handle(GetSubCountiesCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    CountyService countyService = new CountyService(_unitOfWork);
                    var           subcounties   = await countyService.GetSubCountyList(request.CountyId);

                    return(Result <List <SubCountyLookup> > .Valid(subcounties));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Result <List <SubCountyLookup> > .Invalid(e.Message));
                }
            }
        }
        public async Task <Result <AddSubCountiesResponse> > Handle(GetSubCountiesCommand request, CancellationToken cancellationToken)
        {
            try
            {
                LookupLogic ll = new LookupLogic(_unitOfWork);

                if (String.IsNullOrEmpty(request.CountyId))
                {
                    CountyId = 0;
                }
                else
                {
                    CountyId = Convert.ToInt32(request.CountyId);
                }
                if (String.IsNullOrEmpty(request.SubcountyId))
                {
                    SubCountyId = 0;
                }
                else
                {
                    SubCountyId = Convert.ToInt32(request.SubcountyId);
                }



                if (CountyId > 0 && SubCountyId == 0)
                {
                    subcounties = await ll.GetSubCountyList(CountyId);
                }

                return(Result <AddSubCountiesResponse> .Valid(new AddSubCountiesResponse()
                {
                    SubCounties = subcounties
                }));
            }
            catch (Exception e)
            {
                return(Result <AddSubCountiesResponse> .Invalid(e.Message));
            }
        }