using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace HelpdeskDAL { public class ProblemDAO { //Using Repository readonly IRepository<Problem> _repo; public ProblemDAO() { _repo = new HelpdeskRepository<Problem>(); } // // Retrieve Problem by description // public async Task<Problem> GetByDescription(string description) { Problem? selectedProblem; try { selectedProblem = await _repo.GetOne(prob => prob.Description == description); } catch (Exception ex) { Debug.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod()!.Name + " " + ex.Message); throw; } return selectedProblem!; } // // Retrieve All Problems // public async Task<List<Problem>> GetAll() { List<Problem> allProblems; try { allProblems = await _repo.GetAll(); } catch (Exception ex) { Debug.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod()!.Name + " " + ex.Message); throw; } return allProblems; } public async Task<Problem> GetById(int id) { Problem? selectedProblem; try { selectedProblem = await _repo.GetOne(prob => prob.Id == id); } catch (Exception ex) { Debug.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod()!.Name + " " + ex.Message); throw; } return selectedProblem!; } } }