private void Page_Loaded(object sender, RoutedEventArgs e) { using (var Roomdb = new RoomDbContext()) { RoomsListView.ItemsSource = Roomdb.Rooms.ToList(); } }
public CollectionRepository( RoomDbContext roomDbContext, IMapper mapper) { _roomDbContext = roomDbContext; _mapper = mapper; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new RoomDbContext()) { db.Database.Migrate(); }//应用程序启动时将任何待定迁移应用到本地数据库 }
public CollectionFileRepository( RoomDbContext roomDbContext, IMapper mapper, ICollectionFileCacheService collectionFileCacheService, IMemoryCache cache) { _roomDbContext = roomDbContext; _mapper = mapper; _collectionFileCacheService = collectionFileCacheService; _cache = cache; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new RoomDbContext()) { //temporarly for deleting stuff //db.Database.EnsureDeleted(); db.Database.Migrate(); } }
public static List <Room> GetRooms() { using (var db = new RoomDbContext()) { try { List <Room> rooms = db.Rooms.ToList(); return(rooms); } catch { return(null); } } }
private void AddRoomBt_Click(object sender, RoutedEventArgs e) { using (var Roomdb = new RoomDbContext()) { var Room = new Room() { RoomId = int.Parse(Tb_RoomId.Text), RoomName = Tb_RoomName.Text, RoomImagePath = Tb_RoomImgaePath.Text, I2C_Slave_Address = Tb_I2CAddress.Text }; Roomdb.Rooms.Add(Room); Roomdb.SaveChanges(); RoomsListView.ItemsSource = Roomdb.Rooms.ToList(); } }
private void DeletRoomBt_Click(object sender, RoutedEventArgs e) { if (RoomsListView.SelectedItem != null) { var room = RoomsListView.SelectedItem as Room; using (var Roomdb = new RoomDbContext()) { Roomdb.Rooms.Remove(room); Roomdb.SaveChanges(); RoomsListView.ItemsSource = Roomdb.Rooms.ToList(); } } else { return; } }
public static void UpdateSurface(Surface currentSurface) { using (var db = new RoomDbContext()) { try { Surface surface = db.Surfaces.Find(currentSurface.SurfaceId); surface.Title = currentSurface.Title; surface.Description = currentSurface.Description; surface.SurfaceImage = currentSurface.SurfaceImage; db.SaveChanges(); } catch { ErrorMessage.DisplayErrorDialog("Could not Update!"); } } }
public static Room GetRoom(string title) { using (var db = new RoomDbContext()) { try { Room room = db.Rooms.Where(b => b.Title == title) .Include(b => b.Surfaces) .FirstOrDefault(); return(room); } catch { return(null); } } }
// For Existing rooms page public static Room CreateRoom(string title, string description, double volume, double lat, double longt) { using (var db = new RoomDbContext()) { if (db.Rooms.FirstOrDefault(g => g.Title == title) == null) { Room currentroom = new Room { Title = title, Description = description, Lat = lat, Longt = longt, Volume = volume, Surfaces = new List <Surface>() { new Surface(), new Surface(), new Surface(), new Surface(), new Surface(), new Surface() } }; db.Rooms.Add(currentroom); foreach (var surf in currentroom.Surfaces) { db.Surfaces.Add(surf); } db.SaveChanges(); // Return the new room return(GetRoom(currentroom.Title)); } else { // No new room created. return(null); } } }
public static void UpdateRoom(Room room) { using (var db = new RoomDbContext()) { try { // Tror inte denna funkar riktigt Room dbRoom = db.Rooms.Find(room.RoomId); int i = 0; foreach (var surf in room.Surfaces) { dbRoom.Surfaces[i] = surf; i++; } db.SaveChanges(); } catch { ErrorMessage.DisplayErrorDialog("Could not Update!"); } } }
public EquipmentTypeRepository(RoomDbContext context) : base(context) { }
public DepartmentRepository(RoomDbContext context) : base(context) { }
public DestinationFolderRepository(RoomDbContext roomDbContext, IMapper mapper) { _roomDbContext = roomDbContext; _mapper = mapper; }
public RoomRepository(RoomDbContext context) : base(context) { }
public SourceFolderRepository(RoomDbContext roomDbContext, IMapper mapper) { _roomDbContext = roomDbContext; _mapper = mapper; }
public HospitalEquipmentRepository(RoomDbContext context) : base(context) { }
public DbStateService(RoomDbContext roomDbContext) { _roomDbContext = roomDbContext; }