public HttpResponseMessage Get(int id) { Map m = mapRepository.GetMap(id); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(m.Image); result.Content.Headers.ContentType = new MediaTypeHeaderValue(m.ImageType); return(result); }
public int Solution(string input) { char[,] map = mapRepository.GetMap(input); int fewestNumberOfSteps = route.CalculateFewestNumberOfStepsRequiredToVisitEveryNonZeroNumber(map, true); return(fewestNumberOfSteps); }
public FileStreamResult GetMapPreview(string Mapname) { if (Mapname != null) { mapRepository.GetMap(Mapname, User.Identity.Name); TempData["SelectedMap"] = mapRepository.Map.Name; } var stream = new MemoryStream(mapRepository.Map.Image); return(new FileStreamResult(stream, "image/png")); }
public IActionResult Index() { mapRepository.GetMap(TempData.Peek("SelectedMap").ToString(), User.Identity.Name); var map = mapRepository.Map; var FloatArray = new float[map.Size, map.Size]; FloatArray = PerlinNoiseGenerator.GenerateMap(map.Size, map.Seed); if (map.MapType == 1) { FloatArray = IslandMaskGenerator.ApplyIslandMask(map.Size, FloatArray); } var IntegerArray = new int[map.Size, map.Size]; for (var y = 0; y < map.Size; y++) { for (var x = 0; x < map.Size; x++) { IntegerArray[x, y] = (int)(FloatArray[x, y] * 256); } } var width = map.Size; var height = map.Size; var ColorArray = new Color[map.Size, map.Size]; for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { var HeightValue = IntegerArray[x, y]; var color = TileColorSelector.SelectTileColor(HeightValue, map.GroundType); ColorArray[x, y] = color; } } var model = new WorldMapViewModel { MapName = map.Name, Size = map.Size, HeightValues = IntegerArray, TileSize = 40, TileColors = ColorArray }; return(View(model)); }
// POST api/<controller> public HttpResponseMessage Post(MapViewModel mapVm) { Map map = ModelConverter.ToDbMapModel(mapVm); // If the ID is not zero, then edit the map if (map.Id > 0) { mapRepository.UpdateMap(map); } else // If the map has a zero id, then create a new map { map = mapRepository.CreateMap(map); } if (mapVm.SessionId > 0) { mapRepository.AddMapToSession(map.Id, mapVm.SessionId); } mapVm = ModelConverter.ToMapViewModel(mapRepository.GetMap(map.Id)); return(Request.CreateResponse(HttpStatusCode.OK, mapVm)); }