Beispiel #1
0
        public CreateBlockViewModel GetMapByID(int mapID)
        {
            MapPreviewService previewService = new MapPreviewService();

            using (var ctx = new ApplicationDbContext())
            {
                var entity     = ctx.Maps.Single(e => e.ID == mapID);
                var userEntity = ctx.Users.FirstOrDefault(e => e.Id == entity.OwnerID.ToString());

                string preview =
                    previewService.PrintCurrentRoomForCanvas
                    (
                        previewService.GenerateInputRoomFromMap(entity)
                    );

                var mapModel = new MapDetail
                {
                    MapID       = entity.ID,
                    OwnerName   = userEntity.UserName,
                    Name        = entity.Name,
                    Description = entity.Description,
                    SizeX       = entity.SizeX,
                    SizeY       = entity.SizeY,
                    BlockIDs    = BlockIDsByMapID(mapID),
                    MapPreview  = preview
                };

                return(new CreateBlockViewModel
                {
                    MapModel = mapModel
                });
            }
        }
        private string GetMapPreview(int id)
        {
            var svc = new MapPreviewService();

            using (var ctx = new ApplicationDbContext())
            {
                var map = ctx.Maps.Single(e => e.ID == id);
                return(svc.PrintCurrentRoomForCanvas(svc.GenerateInputRoomFromMap(map)));
            }
        }
        private int[] GetMapSize(int id)
        {
            var svc = new MapPreviewService();

            using (var ctx = new ApplicationDbContext())
            {
                var   map    = ctx.Maps.Single(e => e.ID == id);
                int[] output = { map.SizeX, map.SizeY };
                return(output);
            }
        }