using System.Collections.Generic; using System.Data; using Kreta.BusinessLogic.HelperClasses; using Kreta.Core.ConnectionType; using Kreta.DataAccessManual; using Kreta.DataAccessManual.Interfaces; using Kreta.DataAccessManual.ParameterClasses; namespace Kreta.BusinessLogic.Helpers { public class FelmentesHelper : LogicBase { public FelmentesHelper(IConnectionType connectionType) : base(connectionType) { } public List GetFelmentesGrid(FelmentesSearchCo co) { FelmentesSearchPco pco = ConvertToPco(co); var ds = Dal.CustomConnection.Run(ConnectionType, h => { IFelmentesDal dal = h.FelmentesDal(GridParameters); return dal.GetFelmentesGrid(pco, IntezmenyId, TanevId); }); var result = new List(); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dataRow in ds.Tables[0].Rows) { var item = new FelmentesGridItemCo(dataRow); result.Add(item); } } return result; } public FelmentesGridItemCo GetFelmentesById(int felmentesId) { FelmentesSearchPco pco = new FelmentesSearchPco { ID = felmentesId }; var ds = Dal.CustomConnection.Run(ConnectionType, h => { IFelmentesDal dal = h.FelmentesDal(GridParameters); return dal.GetFelmentesGrid(pco, IntezmenyId, TanevId); }); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { return new FelmentesGridItemCo(ds.Tables[0].Rows[0]); } else { return new FelmentesGridItemCo(); } } private FelmentesSearchPco ConvertToPco(FelmentesSearchCo co) { FelmentesSearchPco pco = new FelmentesSearchPco() { ID = co.ID, TanuloNeve = co.TanuloNeve, TanuloOsztalyId = co.TanuloOsztalyId, TantargyId = co.TantargyId, KezdeteDateFrom = co.KezdeteDateFrom, KezdeteDateTo = co.KezdeteDateTo, VegeDateFrom = co.VegeDateFrom, VegeDateTo = co.VegeDateTo, IsTanoraLatogatasaAloli = co.IsTanoraLatogatasaAloli, IsErtekelesAloli = co.IsErtekelesAloli, IsSzovegesenErtekelheto = co.IsSzovegesenErtekelheto, FelmentesOka = co.FelmentesOka, RogzitesDateFrom = co.RogzitesDateFrom, RogzitesDateTo = co.RogzitesDateTo, RogzitoNeve = co.RogzitoNeve, ModositasDateFrom = co.ModositasDateFrom, ModositasDateTo = co.ModositasDateTo, ModositoNeve = co.ModositoNeve, Torolt = co.Torolt }; return pco; } } }