示例#1
0
        public async Task <ActionResult <List <LocationData> > > GetLocalities([FromQuery] int?countyId, int?ballotId)
        {
            try
            {
                var result = await _territoryRepository.GetLocalities(countyId, ballotId);

                if (result.IsSuccess)
                {
                    return(result.Value.Select(c => new LocationData
                    {
                        Id = c.LocalityId,
                        Name = c.Name,
                        CountyId = c.CountyId
                    }).ToList());
                }

                return(StatusCode(500, result.Error));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }