public ActionResult GetPolingStationsByElectoralDistrict([FromBody] ElectoralDistrictDTO electoralDistrictDTO) { List <District> districts = _context.District.Where(d => d.ElectoralDistrictId == electoralDistrictDTO.IdElectoralDistrict).ToList(); List <int> selectStationsId = districts.Select(d => d.StationId ?? 0).ToList(); IQueryable <PollingStation> pollingStations = _context.PollingStation.Include(p => p.Station).Include(p => p.CityDistrict).Include(p => p.Street).Include(p => p.House) .Where(p => selectStationsId.Contains(p.StationId ?? 0)); return(PartialView(pollingStations)); }
public IActionResult SearchPolingStationsByElectoralDistrict([FromBody] ElectoralDistrictDTO electoralDistrictDTO) { List <District> districts = _context.District.Where(d => d.ElectoralDistrictId == electoralDistrictDTO.IdElectoralDistrict).ToList(); List <int> selectStationsId = districts.Select(d => d.StationId ?? 0).ToList(); List <PollingStation> pollingStations = _context.PollingStation.Include(p => p.CityDistrict).Include(p => p.Street).Include(p => p.House) .Where(p => selectStationsId.Contains(p.StationId ?? 0)).ToList(); List <PollingStationDTO> pollingStationDTOs = pollingStations.Select( p => new PollingStationDTO { IdPollingStation = p.IdPollingStation, Name = p.Name, CityName = p.CityDistrict.Name, StreetName = p.Street.Name, HouseName = p.House.Name }).ToList(); return(Ok(pollingStationDTOs)); }
public async Task <List <FriendDTO> > SearchFriendsByElectoralDistrict([FromBody] ElectoralDistrictDTO electoralDistrictDTO) { List <Friend> friends = await _serviceFriends.SearchFriendsByElectoralDistrict(electoralDistrictDTO).ToListAsync(); List <FriendDTO> friendDTOs = friends.Select(frnd => new FriendDTO { IdFriend = frnd.IdFriend, FamilyName = frnd.FamilyName, Name = frnd.Name, PatronymicName = frnd.PatronymicName, DateBirth = frnd.DateBirth.ToString(), City = frnd.City.Name, CityDistrict = frnd.CityDistrict.Name, Street = frnd.Street.Name, Microdistrict = frnd.MicroDistrict.Name, House = frnd.House.Name, Apartment = frnd.Apartment, Telephone = frnd.Telephone, ElectiralDistrict = frnd.ElectoralDistrict.Name, PollingStationName = frnd.Station.Name, Organization = frnd.Organization, FieldActivityName = frnd.FieldActivity.Name, PhoneNumberResponsible = frnd.PhoneNumberResponsible, DateRegistrationSite = frnd.DateRegistrationSite.ToString(), VotingDate = frnd.VotingDate.ToString(), Vote = frnd.Voter.ToString(), TextQRcode = frnd.TextQRcode, Email = frnd.Email, Description = frnd.Description, Group = frnd.GroupU.Name, UserId = frnd.UserId, UserName = frnd.User.UserName }).ToList(); return(friendDTOs); }