ILocation CreateLocation(NewGameParams param) { var locationParam = new LocationParams() { Height = param.MapHeight, Width = param.MapWidth, PlayerNumber = param.PlayerNumber }; return(_serviceContainer.GetService <ILocationManager>().CreateLocation(locationParam)); }
public async Task <IActionResult> GetLocations([FromQuery] LocationParams locationParams) { var locations = await _locationRepo.GetLocations(locationParams); var locationList = _mapper.Map <ICollection <LocationListDto> >(locations); Response.AddPagination(locations.CurrentPage, locations.PageSize, locations.TotalCount, locations.TotalPages); return(Ok(locationList)); }
public static LocationParams Validate(IQueryCollection query) { var QueryParam = new LocationParams() { Location = query["location"], Categories = query["categories"] }; if (QueryParam.Categories != null && QueryParam.Location != null) { return(QueryParam); } else { return(null); } }
public Interfaces.Location.Models.ILocation CreateLocation(LocationParams param) { var mapParams = new MapCreateRequest() { Height = param.Height, Width = param.Width }; var map = _mapWorker.CreateMap(mapParams); if (map.MaxPlayers < param.PlayerNumber) { throw new ArgumentException("PlayerNumber"); } var players = _playerCreator.CreatePlayers(param.PlayerNumber); var location = new Location(map, players); return(location); }
public async Task <PageList <Location> > GetLocations(LocationParams locationParams) { var locations = _dbContext.Locations .Include(l => l.LocationType) .Where(l => l.IsArchived == false) .AsQueryable(); if (!string.IsNullOrEmpty(locationParams.Name)) { locations = locations.Where(l => l.Name.Contains(locationParams.Name)); } if (!string.IsNullOrEmpty(locationParams.LocationType)) { locations = locations.Where(l => l.LocationType.Name == locationParams.LocationType); } if (string.Equals(locationParams.Direction, "ASC")) { switch (locationParams.OrderBy.ToLower()) { case "name": locations = locations.OrderBy(l => l.Name); break; case "address": locations = locations.OrderBy(l => l.Address); break; case "locationtype": locations = locations.OrderBy(l => l.LocationType.Name); break; default: locations = locations.OrderBy(l => l.Name); break; } } else { switch (locationParams.OrderBy.ToLower()) { case "name": locations = locations.OrderByDescending(l => l.Name); break; case "address": locations = locations.OrderByDescending(l => l.Address); break; case "locationtype": locations = locations.OrderByDescending(l => l.LocationType.Name); break; default: locations = locations.OrderByDescending(l => l.Name); break; } } //return await locations.ToListAsync(); return(await PageList <Location> .CreateAsync(locations, locationParams.PageNumber, locationParams.PageSize)); }