Skip to content

Commit

Permalink
Selected item bug fixed
Browse files Browse the repository at this point in the history
Delete/Edit functionality isn't working
  • Loading branch information
xtenzQ committed Mar 12, 2019
1 parent d19237a commit a2544eb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ResearchersWPF.Data/Managers/ArticleManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using ResearchersWPF.Data.IManagers;
using ResearchersWPF.Data.Model;

Expand Down Expand Up @@ -45,7 +46,8 @@ public List<Article> FindByResearcher(int researcherId)
{
using (var context = new ResDbContext())
{
return context.Researchers.First(i => i.Id == researcherId).Articles.ToList();
return context.Articles.Where(s => s.ResearcherId == researcherId).ToList();
//return context.Researchers.First(i => i.Id == researcherId).Articles.ToList();
}
}

Expand Down
4 changes: 3 additions & 1 deletion ResearchersWPF.Data/Managers/MonographManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using ResearchersWPF.Data.IManagers;
using ResearchersWPF.Data.Model;

Expand Down Expand Up @@ -53,7 +54,8 @@ public List<Monograph> FindByResearcher(int researcherId)
{
using (var context = new ResDbContext())
{
return context.Researchers.First(i => i.Id == researcherId).Monographs.ToList();
return context.Monographs.Where(s => s.ResearcherId == researcherId).ToList();
//return context.Researchers.First(i => i.Id == researcherId).Monographs.ToList();
}
}

Expand Down
4 changes: 3 additions & 1 deletion ResearchersWPF.Data/Managers/PresentationManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using ResearchersWPF.Data.IManagers;
using ResearchersWPF.Data.Model;

Expand Down Expand Up @@ -50,7 +51,8 @@ public List<Presentation> FindByResearcher(int researcherId)
{
using (var context = new ResDbContext())
{
return context.Researchers.First(i => i.Id == researcherId).Presentations.ToList();
return context.Presentations.Where(s => s.ResearcherId == researcherId).ToList();
//return context.Researchers.First(i => i.Id == researcherId).Presentations.ToList();
}
}

Expand Down
7 changes: 6 additions & 1 deletion ResearchersWPF.Data/Managers/ReportManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Extensions.Internal;
using ResearchersWPF.Data.IManagers;
using ResearchersWPF.Data.Model;

Expand Down Expand Up @@ -51,7 +53,10 @@ public List<Report> FindByResearcher(int researcherId)
{
using (var context = new ResDbContext())
{
return context.Researchers.First(i => i.Id == researcherId).Reports.ToList();
context.ChangeTracker.AutoDetectChangesEnabled = false;

return context.Reports.Where(s => s.ResearcherId == researcherId).ToList();
//return context.Researchers.First(i => i.Id == researcherId).Reports.ToList();
}
}

Expand Down
Binary file modified ResearchersWPF.Service/App_Data/Researchers.db
Binary file not shown.
4 changes: 4 additions & 0 deletions ResearchersWPF.UI/ViewModel/MonographViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public int PageCount
internal MonographViewModel(svcMonograph.Monograph monograph)
{
Id = monograph.Id;
Name = monograph.Name;
CoauthorLastName = monograph.CoauthorLastName;
CoauthorFirstName = monograph.CoauthorFirstName;
CoauthorMiddleName = monograph.CoauthorMiddleName;
Expand All @@ -130,6 +131,7 @@ private void Update()
{
monographServiceClient.AddMonograph(Researcher.Id, new svcMonograph.Monograph
{
Name = Name,
CoauthorLastName = CoauthorLastName,
CoauthorFirstName = CoauthorFirstName,
CoauthorMiddleName = CoauthorMiddleName,
Expand All @@ -142,6 +144,7 @@ private void Update()
{
monographServiceClient.UpdateMonograph(new svcMonograph.Monograph
{
Name = Name,
Id = Id,
CoauthorLastName = CoauthorLastName,
CoauthorFirstName = CoauthorFirstName,
Expand All @@ -163,6 +166,7 @@ private void Delete()
private void Undo()
{
if (Mode != Mode.Edit) return;
Name = _originalValue.Name;
CoauthorLastName = _originalValue.CoauthorLastName;
CoauthorFirstName = _originalValue.CoauthorFirstName;
CoauthorMiddleName = _originalValue.CoauthorMiddleName;
Expand Down
24 changes: 20 additions & 4 deletions ResearchersWPF.UI/ViewModel/ResearcherViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ internal ResearcherViewModel() { }

internal ObservableCollection<ArticleViewModel> GetArticles()
{
_articles = new ObservableCollection<ArticleViewModel>();
if (_articles == null)
{
_articles = new ObservableCollection<ArticleViewModel>();
}
_articles.Clear();
var articleServiceClient = new svcArticle.ArticleServiceClient();
foreach (var article in articleServiceClient.GetArticleByResearcher(Id))
{
Expand All @@ -216,7 +220,11 @@ internal ObservableCollection<ArticleViewModel> GetArticles()

internal ObservableCollection<MonographViewModel> GetMonographs()
{
_monographs = new ObservableCollection<MonographViewModel>();
if (_monographs == null)
{
_monographs = new ObservableCollection<MonographViewModel>();
}
_monographs.Clear();
var monographServiceClient = new svcMonograph.MonographServiceClient();
foreach (var monograph in monographServiceClient.GetMonographByResearcher(Id))
{
Expand All @@ -229,7 +237,11 @@ internal ObservableCollection<MonographViewModel> GetMonographs()

internal ObservableCollection<PresentationViewModel> GetPresentations()
{
_presentations = new ObservableCollection<PresentationViewModel>();
if (_presentations == null)
{
_presentations = new ObservableCollection<PresentationViewModel>();
}
_presentations.Clear();
var presentationServiceClient = new svcPresentation.PresentationServiceClient();
foreach (var presentation in presentationServiceClient.GetPresentationByResearcher(Id))
{
Expand All @@ -242,7 +254,11 @@ internal ObservableCollection<PresentationViewModel> GetPresentations()

internal ObservableCollection<ReportViewModel> GetReports()
{
_reports = new ObservableCollection<ReportViewModel>();
if (_reports == null)
{
_reports = new ObservableCollection<ReportViewModel>();
}
_reports.Clear();
var reportServiceClient = new svcReport.ReportServiceClient();
foreach (var report in reportServiceClient.GetReportByResearcher(Id))
{
Expand Down

0 comments on commit a2544eb

Please sign in to comment.