//hàm trả về list position cần đi và text hướng dẫn đi public async Task <List <SuggestRouteResponse> > GetRouteBaseOnExhibitForUser(List <int> exhibitId) { //list trả về List <SuggestRouteResponse> listResponse = new List <SuggestRouteResponse>(); List <RoomResponse> listRoom = await _roomService.GetRoomFromListExhibit(exhibitId); List <int> listRoomId = new List <int>(); foreach (var item in listRoom) { listRoomId.Add(item.Id); } ShortestPathResponse shortestPath = await GetShortestPath(listRoomId); //trả về list đường đi List <uint> listRoute = shortestPath.Path; //convert nó thành list int để add vào response trả về List <int> convertlistRoute = new List <int>(); foreach (var item in listRoute) { convertlistRoute.Add(Convert.ToInt32(item)); } //xong phần get list suggest route //get text route base on language string textRouteVi = "Lộ trình:\n"; string textRouteEng = "Route:\n"; //lấy list position dựa trên list route //text Viet foreach (var item in convertlistRoute) { Position position = _unitOfWork.Repository <Position>().GetById(item); textRouteVi = textRouteVi + "-" + position.DescriptionVie + "\n"; textRouteEng = textRouteEng + "-" + position.DescriptionEng + "\n"; } SuggestRouteResponse suggestRouteResponse = new SuggestRouteResponse(convertlistRoute, textRouteVi, textRouteEng); listResponse.Add(suggestRouteResponse); return(listResponse.ToList()); }
public async Task <List <SuggestRouteResponse> > GetRouteToBackToStartPoint(int roomId) { List <SuggestRouteResponse> listResponse = new List <SuggestRouteResponse>(); List <int> listRouteToBack = await GetShortestPathToBackToStartPoint(roomId); string textRouteVi = "Lộ trình:\n"; string textRouteEng = "Route:\n"; foreach (var item in listRouteToBack) { Position position = _unitOfWork.Repository <Position>().GetById(item); textRouteVi = textRouteVi + "-" + position.DescriptionVie + "\n"; textRouteEng = textRouteEng + "-" + position.DescriptionEng + "\n"; } SuggestRouteResponse suggestRouteResponse = new SuggestRouteResponse(listRouteToBack, textRouteVi, textRouteEng); listResponse.Add(suggestRouteResponse); return(listResponse.ToList()); }