Loading RoomiezApp/RoomiezApp/Database/Manager/FlatManager.cs +4 −4 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ namespace RoomiezApp.Database.Manager public void FillFlatUsers(Flat f) { f.Roommates.Clear(); f.ClearRoommates(); string q = $@" SELECT id, username, is_head FROM Roommate WHERE flat_id == {f.Id} Loading @@ -75,7 +75,7 @@ namespace RoomiezApp.Database.Manager while (reader.Read()) { Roommate r = Mapper.MapRoommate(reader); f.Roommates.Add(r); f.AddRoommate(r); } } catch (Exception ex) Loading @@ -87,7 +87,7 @@ namespace RoomiezApp.Database.Manager public void FillFlatTasks(Flat f) { f.Tasks.Clear(); f.tasks.Clear(); string q = $@" SELECT id, title, description, deadline, done, roommate_id FROM Task Loading @@ -100,7 +100,7 @@ namespace RoomiezApp.Database.Manager while (reader.Read()) { f.Tasks.Add(Mapper.MapTask(reader, f.Roommates)); f.tasks.Add(Mapper.MapTask(reader, f.Roommates)); } } catch (Exception ex) Loading RoomiezApp/RoomiezApp/Database/RoomiezDbContext.csdeleted 100644 → 0 +0 −41 Original line number Diff line number Diff line using RoomiezApp.Model; using System.Data.Entity; using System.Data.SQLite; using System.Data.SQLite.EF6; namespace RoomiezApp.Database { [DbConfigurationType(typeof(SQLiteConfiguration))] public class AppDbContext : DbContext { public DbSet<Flat> Flats { get; set; } public DbSet<Roommate> Roommates { get; set; } // Add DbSet properties for other entities public AppDbContext() : base("name=RoomiezDbConnectionString") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Task>() .HasRequired(t => t.Assignee) .WithMany(r => r.Tasks) .HasForeignKey(t => t.AssigneeId); // Additional configuration for Flat and Roommate entities if needed base.OnModelCreating(modelBuilder); } } public class SQLiteConfiguration : DbConfiguration { public SQLiteConfiguration() { SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); SetProviderServices("System.Data.SQLite", (System.Data.Entity.Core.Common.DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(System.Data.Entity.Core.Common.DbProviderServices))); } } } RoomiezApp/RoomiezApp/Forms/EditUsers.cs +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ namespace RoomiezApp.Forms { var roommateListViewItem = new ListViewItem(roommate.Id + ""); roommateListViewItem.SubItems.Add(roommate.Name); roommateListViewItem.SubItems.Add(roommate.HeadRoommate ? "yes" : "no"); roommateListViewItem.SubItems.Add(roommate.IsHeadRoommate() ? "yes" : "no"); roommateListView.Items.Add(roommateListViewItem); Loading RoomiezApp/RoomiezApp/Forms/MainWindowPanels/Summary.cs +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ namespace RoomiezApp.Forms.MainWindowPanels fillToDoListView(); flatNameLabel.Text = _flat.Name; changeFlatNameTextbox.Hide(); if (!_user.HeadRoommate) if (!_user.IsHeadRoommate()) { editUsersButton.Hide(); changeFlatNameButton.Hide(); Loading @@ -59,7 +59,7 @@ namespace RoomiezApp.Forms.MainWindowPanels private void fillToDoListView() { todoListView.Items.Clear(); var tasks = _flat.Tasks.Where(t => t.Assignee.Id == _user.Id && t.Completed == false).OrderBy(t => t.Deadline).Take(10); var tasks = _flat.tasks.Where(t => t.Assignee.Id == _user.Id && t.Completed == false).OrderBy(t => t.Deadline).Take(10); foreach (var task in tasks) { Loading RoomiezApp/RoomiezApp/Forms/MainWindowPanels/Tasks.cs +2 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ namespace RoomiezApp.Forms.MainWindowPanels private void filterTasks() { IEnumerable<Task> tasks = _flat.Tasks; IEnumerable<Task> tasks = _flat.tasks; if (showCompletedCheckBox.Checked == false) { tasks = tasks.Where(t => incompleteFilter(t)); Loading Loading @@ -116,7 +116,7 @@ namespace RoomiezApp.Forms.MainWindowPanels { var selectedRow = taskGridView.SelectedRows[0]; int id = (int) selectedRow.Cells["ID"].Value; _flat.Tasks.RemoveAll(t => t.Id == id); _flat.tasks.RemoveAll(t => t.Id == id); taskGridView.Rows.Remove(selectedRow); _tM.DeleteTask(id); } Loading Loading
RoomiezApp/RoomiezApp/Database/Manager/FlatManager.cs +4 −4 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ namespace RoomiezApp.Database.Manager public void FillFlatUsers(Flat f) { f.Roommates.Clear(); f.ClearRoommates(); string q = $@" SELECT id, username, is_head FROM Roommate WHERE flat_id == {f.Id} Loading @@ -75,7 +75,7 @@ namespace RoomiezApp.Database.Manager while (reader.Read()) { Roommate r = Mapper.MapRoommate(reader); f.Roommates.Add(r); f.AddRoommate(r); } } catch (Exception ex) Loading @@ -87,7 +87,7 @@ namespace RoomiezApp.Database.Manager public void FillFlatTasks(Flat f) { f.Tasks.Clear(); f.tasks.Clear(); string q = $@" SELECT id, title, description, deadline, done, roommate_id FROM Task Loading @@ -100,7 +100,7 @@ namespace RoomiezApp.Database.Manager while (reader.Read()) { f.Tasks.Add(Mapper.MapTask(reader, f.Roommates)); f.tasks.Add(Mapper.MapTask(reader, f.Roommates)); } } catch (Exception ex) Loading
RoomiezApp/RoomiezApp/Database/RoomiezDbContext.csdeleted 100644 → 0 +0 −41 Original line number Diff line number Diff line using RoomiezApp.Model; using System.Data.Entity; using System.Data.SQLite; using System.Data.SQLite.EF6; namespace RoomiezApp.Database { [DbConfigurationType(typeof(SQLiteConfiguration))] public class AppDbContext : DbContext { public DbSet<Flat> Flats { get; set; } public DbSet<Roommate> Roommates { get; set; } // Add DbSet properties for other entities public AppDbContext() : base("name=RoomiezDbConnectionString") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Task>() .HasRequired(t => t.Assignee) .WithMany(r => r.Tasks) .HasForeignKey(t => t.AssigneeId); // Additional configuration for Flat and Roommate entities if needed base.OnModelCreating(modelBuilder); } } public class SQLiteConfiguration : DbConfiguration { public SQLiteConfiguration() { SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); SetProviderServices("System.Data.SQLite", (System.Data.Entity.Core.Common.DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(System.Data.Entity.Core.Common.DbProviderServices))); } } }
RoomiezApp/RoomiezApp/Forms/EditUsers.cs +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ namespace RoomiezApp.Forms { var roommateListViewItem = new ListViewItem(roommate.Id + ""); roommateListViewItem.SubItems.Add(roommate.Name); roommateListViewItem.SubItems.Add(roommate.HeadRoommate ? "yes" : "no"); roommateListViewItem.SubItems.Add(roommate.IsHeadRoommate() ? "yes" : "no"); roommateListView.Items.Add(roommateListViewItem); Loading
RoomiezApp/RoomiezApp/Forms/MainWindowPanels/Summary.cs +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ namespace RoomiezApp.Forms.MainWindowPanels fillToDoListView(); flatNameLabel.Text = _flat.Name; changeFlatNameTextbox.Hide(); if (!_user.HeadRoommate) if (!_user.IsHeadRoommate()) { editUsersButton.Hide(); changeFlatNameButton.Hide(); Loading @@ -59,7 +59,7 @@ namespace RoomiezApp.Forms.MainWindowPanels private void fillToDoListView() { todoListView.Items.Clear(); var tasks = _flat.Tasks.Where(t => t.Assignee.Id == _user.Id && t.Completed == false).OrderBy(t => t.Deadline).Take(10); var tasks = _flat.tasks.Where(t => t.Assignee.Id == _user.Id && t.Completed == false).OrderBy(t => t.Deadline).Take(10); foreach (var task in tasks) { Loading
RoomiezApp/RoomiezApp/Forms/MainWindowPanels/Tasks.cs +2 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ namespace RoomiezApp.Forms.MainWindowPanels private void filterTasks() { IEnumerable<Task> tasks = _flat.Tasks; IEnumerable<Task> tasks = _flat.tasks; if (showCompletedCheckBox.Checked == false) { tasks = tasks.Where(t => incompleteFilter(t)); Loading Loading @@ -116,7 +116,7 @@ namespace RoomiezApp.Forms.MainWindowPanels { var selectedRow = taskGridView.SelectedRows[0]; int id = (int) selectedRow.Cells["ID"].Value; _flat.Tasks.RemoveAll(t => t.Id == id); _flat.tasks.RemoveAll(t => t.Id == id); taskGridView.Rows.Remove(selectedRow); _tM.DeleteTask(id); } Loading