private void SetMirrorLeanDirection(ref MirrorDto mirrorDto, string types) { if (types.Substring(0, 1).Equals("L")) { mirrorDto.MirrorLeanDirection = Common.MirrorLeanDirections.Left; } else { mirrorDto.MirrorLeanDirection = Common.MirrorLeanDirections.Right; } }
private void SetMirrorReflection(ref MirrorDto mirrorDto, string types) { var value = types.Substring(1, 1).ToUpper(); if (value == "L") { mirrorDto.MirrorReflection = Common.MirrorReflections.Left; } else if (value == "R") { mirrorDto.MirrorReflection = Common.MirrorReflections.Right; } else { mirrorDto.MirrorReflection = Common.MirrorReflections.Both; } }
public void SaveToDatabase(MazeDataFileModel mazeDataFileModel) { var mazeBoardDto = new MazeBoardDto(); var mazeRooms = new List <MazeRoomDto>(); var xCoord = mazeDataFileModel.MazeSizeData.Item1; var yCoord = mazeDataFileModel.MazeSizeData.Item2; for (int x = 0; x < xCoord; x++) { for (int y = 0; y < yCoord; y++) { var mazeRoom = new MazeRoomDto() { XCoordinate = x, YCoordinate = y }; mazeRooms.Add(mazeRoom); } } mazeBoardDto.MazeRooms = mazeRooms; int lazerGunX = mazeDataFileModel.LazerGunData.Item1; int lazerGunY = mazeDataFileModel.LazerGunData.Item2; string lazerGunOrientation = mazeDataFileModel.LazerGunData.Item3; foreach (var room in mazeRooms) { foreach (var mirrorData in mazeDataFileModel.MirrorData) { var x = mirrorData.Item1; var y = mirrorData.Item2; var types = mirrorData.Item3; if (room.XCoordinate == x && room.YCoordinate == y) { var mirror = new MirrorDto(); if (!string.IsNullOrEmpty(types)) { var length = types.Length; switch (length) { case 1: SetMirrorLeanDirection(ref mirror, types); break; case 2: SetMirrorLeanDirection(ref mirror, types); SetMirrorReflection(ref mirror, types); break; } } room.Mirror = mirror; } } if (room.XCoordinate == lazerGunX && room.YCoordinate == lazerGunY) { room.LazerGun = new LazerGunDto() { XCoordinate = lazerGunX, YCoordinate = lazerGunY }; if (lazerGunOrientation == "H") { room.LazerGun.LazerOrientation = Common.LazerOrientations.Horizontal; } if (lazerGunOrientation == "V") { room.LazerGun.LazerOrientation = Common.LazerOrientations.Vertical; } } } base.UnitOfWork.MazeBoards.Insert(base.Mapper.Map <MazeBoard>(mazeBoardDto)); }
public void Update(string id, MirrorDto mirror) { this.command.Update(id, mirror); }
public IMirror Add(MirrorDto dto) { var mirror = this.command.Add(dto); return(mirror); }