public async void Load() { BuildingLoad = true; bool connect = await WebData.CheckConnection(); if (connect == false) { return; } DependencyService.Get <IToast>().Show("Загрузка здания"); FloorData.Floors = new List <Floor>(); RoomData.Rooms = new List <Room>(); WorkerData.Workers = new List <Worker>(); PointData.Points = new List <PointM>(); PointData.RoomPoints = new List <PointM>(); PointData.CurrentFloorRoomPoints = new List <PointM>(); EdgeData.Edges = new List <EdgeM>(); EdgeData.Ways = new List <EdgeM>(); EdgeData.CurrentFloorWalls = new List <EdgeM>(); NoteData.Notes = new List <Note>(); List <Floor> floors = await new FloorService().GetFloors(Current.BuildingId); List <Room> rooms = await new RoomService().GetRooms(Current.BuildingId); List <Worker> workers = await new WorkerService().GetWorkers(Current.BuildingId); List <PointM> points = await new PointService().GetPoints(Current.BuildingId); List <EdgeM> edges = await new EdgeService().GetEdges(Current.BuildingId); List <Note> notes = await new NoteService().GetPublic(Current.BuildingId); List <Note> clientnotes = null; // получить все публичные заметки не текущего пользователя if (Client.CurrentClient?.ClientId != null) { notes = notes.Where(n => n.ClientId != Client.CurrentClient.ClientId).ToList(); clientnotes = await new NoteService().GetClient(Client.CurrentClient.ClientId); } foreach (var n in notes) { n.ClientId = null; } Authorization.RemoveNonLoadedRoomId(clientnotes, rooms); DbService.RemoveCurrentBuilding(); try { DbService.AddFloor(floors); DbService.AddRoom(rooms); DbService.AddWorker(workers); DbService.AddPoing(points); DbService.AddEdge(edges); DbService.SaveDb(); DbService.AddNote(notes); DbService.AddNote(clientnotes); } catch (System.Exception e) { if (e is Microsoft.EntityFrameworkCore.DbUpdateException || e is System.InvalidCastException) { // DbService.RemoveCurrentBuilding(); DependencyService.Get <IToast>().Show("Загруженые здания некорректны"); } BuildingLoad = false; return; } FloorData.Floors = DbService.LoadAllFloors(); RoomData.Rooms = DbService.LoadAllRooms(); WorkerData.Workers = DbService.LoadAllWorkers(); PointData.Points = DbService.LoadAllPoints(); EdgeData.Edges = DbService.LoadAllEdges(); NoteData.Notes = DbService.LoadAllNotes(); BuildingData.CurrentBuilding = Current; PointData.RoomPoints = PointData.Points .Where(p => p.IsWaypoint == true) .Where(c => c.Room != null).ToList(); DependencyService.Get <IToast>().Show("Здание загружено"); DownloadBut.Text = "Обновить"; BuildingLoad = false; BuildingPage.isUpdate = true; RoomGroup.UpdateList(); }