125 lines
5.2 KiB
C#
125 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.Client.KGR;
|
|
using Kreta.Client.KGR.Model;
|
|
using Kreta.Core.ConnectionType;
|
|
using Kreta.DataAccessManual;
|
|
|
|
namespace Kreta.BusinessLogic.Helpers
|
|
{
|
|
public class KotvallKezelesHelper : LogicBase
|
|
{
|
|
public KotvallKezelesHelper(IConnectionType connectionType) : base(connectionType)
|
|
{
|
|
}
|
|
|
|
public List<KotvallItemCo> GetKotvallItemList(IKGRClient kGRClient, Guid intezmenyEgyediAzonosito, KotvallSearchCo searchCo)
|
|
{
|
|
var tanevSorszam = searchCo.TanevId.HasValue ? Dal.CustomConnection.Run(ConnectionType, (h) =>
|
|
{
|
|
return h.TanevDal().Get(searchCo.TanevId.Value).Sorszam;
|
|
}) : null;
|
|
var beszerzesLista = kGRClient.GetIntezmenyiBeszerzesList(intezmenyEgyediAzonosito, tanevSorszam);
|
|
return FilterKotvallList(searchCo, beszerzesLista.Select(x => new KotvallItemCo(x)).ToList());
|
|
}
|
|
|
|
public List<KotvallItemCo> GetKotvallItemListExport(IKGRClient kGRClient, Guid intezmenyEgyediAzonosito, KotvallSearchCo searchCo)
|
|
{
|
|
var tanevSorszam = searchCo.TanevId.HasValue ? Dal.CustomConnection.Run(ConnectionType, (h) =>
|
|
{
|
|
return h.TanevDal().Get(searchCo.TanevId.Value).Sorszam;
|
|
}) : null;
|
|
var beszerzesLista = kGRClient.GetIntezmenyiBeszerzesExport(intezmenyEgyediAzonosito, tanevSorszam);
|
|
return FilterKotvallList(searchCo, beszerzesLista.Select(x => new KotvallItemCo(x)).ToList());
|
|
}
|
|
|
|
public KotvallItemCo SaveKotvallItem(IKGRClient kGRClient, KotvallItemCo co)
|
|
{
|
|
var model = ConvertCoToModel(co);
|
|
model.TanevId = Dal.CustomConnection.Run(ConnectionType, (h) =>
|
|
{
|
|
return h.TanevDal().Get(co.TanevId.Value).Sorszam;
|
|
});
|
|
return new KotvallItemCo(kGRClient.SaveIntezmenyiBeszerzes(model));
|
|
}
|
|
|
|
public KotvallItemCo GetKotvallItem(IKGRClient kGRClient, Guid intezmenyEgyediAzonosito, int id)
|
|
{
|
|
return new KotvallItemCo(kGRClient.GetIntezmenyiBeszerzes(intezmenyEgyediAzonosito, id));
|
|
}
|
|
|
|
public List<KotvallStatuszItemCo> GetKotvallStatusList(IKGRClient kGRClient)
|
|
{
|
|
var allapotLista = kGRClient.GetIntezmenyiBeszerzesAdatszotarAllapotList();
|
|
return allapotLista.Select(x => new KotvallStatuszItemCo(x)).ToList();
|
|
}
|
|
|
|
public List<KotvallTargyItemCo> GetKotvallTargyList(IKGRClient kGRClient)
|
|
{
|
|
var targyLista = kGRClient.GetIntezmenyiBeszerzesAdatszotarTargyList();
|
|
return targyLista.Select(x => new KotvallTargyItemCo(x)).ToList();
|
|
}
|
|
|
|
public void KotvallVisszavonas(IKGRClient kGRClient, KotvallVisszavonasCo co)
|
|
{
|
|
kGRClient.PostIntezmenyiBeszerzesVisszavonas(co.ConvertToRequest());
|
|
}
|
|
|
|
private List<KotvallItemCo> FilterKotvallList(KotvallSearchCo searchCo, List<KotvallItemCo> list)
|
|
{
|
|
var filtered = list.AsEnumerable();
|
|
if (!string.IsNullOrWhiteSpace(searchCo.Sorszam))
|
|
{
|
|
filtered = filtered.Where(x => x.Sorszam.Contains(searchCo.Sorszam));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(searchCo.BeszerzesTargya))
|
|
{
|
|
filtered = filtered.Where(x => x.BeszerzesTargya.Contains(searchCo.BeszerzesTargya));
|
|
}
|
|
if (searchCo.BruttoErtekTol.HasValue)
|
|
{
|
|
filtered = filtered.Where(x => x.BruttoErtek >= searchCo.BruttoErtekTol.Value);
|
|
}
|
|
if (searchCo.BruttoErtekIg.HasValue)
|
|
{
|
|
filtered = filtered.Where(x => x.BruttoErtek <= searchCo.BruttoErtekIg.Value);
|
|
}
|
|
if (searchCo.BejelentoIdpEgyediAzonosito.HasValue)
|
|
{
|
|
filtered = filtered.Where(x => x.BejelentoIdpEgyediAzonosito == searchCo.BejelentoIdpEgyediAzonosito);
|
|
}
|
|
if (searchCo.StatuszId.HasValue)
|
|
{
|
|
filtered = filtered.Where(x => x.StatuszId == searchCo.StatuszId.Value);
|
|
}
|
|
return filtered.ToList();
|
|
}
|
|
|
|
public IntezmenyiBeszerzesModel ConvertCoToModel(KotvallItemCo co)
|
|
{
|
|
return new IntezmenyiBeszerzesModel
|
|
{
|
|
Id = co.Id,
|
|
TargyId = co.TargyId,
|
|
TargyNev = co.TanevNev,
|
|
VarhatoEllenertekBrutto = co.BruttoErtek,
|
|
IdpEgyediAzonosito = co.BejelentoIdpEgyediAzonosito.ToString(),
|
|
EloTag = co.EloTag,
|
|
CsaladiNev = co.CsaladiNev,
|
|
Utonev = co.Utonev,
|
|
TanevId = co.TanevId,
|
|
TanevNev = co.TanevNev,
|
|
AllapotId = co.StatuszId,
|
|
AllapotNev = co.StatuszNeve,
|
|
Sorszam = co.Sorszam,
|
|
Leiras = co.Leiras,
|
|
VisMajorIndok = co.VisMajorIndok,
|
|
OktatasiAzonosito = co.OktatasiAzonosito,
|
|
IntezmenyEgyediAzonosito = co.IntezmenyEgyediAzonosito.ToString(),
|
|
LetrehozoEmail = co.LetrehozoEmail
|
|
};
|
|
}
|
|
}
|
|
}
|