public async Task <ResultDto> Add(RoomInput item, int mapId, int roomId, string position) { var result = new ResultDto { Message = "" }; try { var map = await _mapDomainService.Get(mapId); if (map == null) { result.Message = $"参数错误(mapId={mapId})"; return(result); } var room = _mapper.Map <RoomEntity>(item); room.MapId = mapId; await _roomDomainService.Add(room); if (roomId > 0) { var oldRoom = await _roomDomainService.Get(roomId); if (oldRoom != null && oldRoom.MapId == mapId) { switch (position) { case "west": if (oldRoom.East == 0) { oldRoom.East = room.Id; oldRoom.EastName = room.Name; room.West = oldRoom.Id; room.WestName = oldRoom.Name; } break; case "east": if (oldRoom.West == 0) { oldRoom.West = room.Id; oldRoom.WestName = room.Name; room.East = oldRoom.Id; room.EastName = oldRoom.Name; } break; case "south": if (oldRoom.South == 0) { oldRoom.South = room.Id; oldRoom.SouthName = room.Name; room.North = oldRoom.Id; room.NorthName = oldRoom.Name; } break; case "north": if (oldRoom.North == 0) { oldRoom.North = room.Id; oldRoom.NorthName = room.Name; room.South = oldRoom.Id; room.SouthName = oldRoom.Name; } break; } } } await _operatorLogDomainService.AddSuccess(new OperatorLogEntity { Type = OperatorLogType.添加地图, Content = JsonConvert.SerializeObject(item) }); await Commit(); result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.添加地图, Content = $"Data={JsonConvert.SerializeObject(item)},ErrorMessage={result.Message}" }); await Commit(); } return(result); }
public async Task <MapEntity> Get(int id) { return(await _mapDomainService.Get(id)); }