92 lines
3.4 KiB
C#
92 lines
3.4 KiB
C#
using System;
|
|
using System.Data;
|
|
using Kreta.BusinessLogic.Interfaces;
|
|
using Kreta.Client.FileService.Request;
|
|
using Kreta.Core.ConnectionType;
|
|
using Kreta.Core.Enum;
|
|
using Kreta.Core.Exceptions;
|
|
using Kreta.DataAccess.Interfaces;
|
|
using Kreta.DataAccessManual;
|
|
using Kreta.Resources;
|
|
|
|
namespace Kreta.BusinessLogic.Helpers
|
|
{
|
|
public class OraFileHelper : LogicBase
|
|
{
|
|
#region Fields
|
|
|
|
private readonly IFileServiceHelper fileServiceHelper;
|
|
|
|
#endregion Fields
|
|
|
|
public OraFileHelper(IConnectionType connectionType) : base(connectionType) { }
|
|
|
|
public OraFileHelper(IConnectionType connectionType, IFileServiceHelper fileServiceHelper) : base(connectionType)
|
|
{
|
|
this.fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
|
}
|
|
|
|
/// INFO: Mobil használja
|
|
public void InsertFileToOraFile(int DKT_FileId, int? orarendiOraId, int? tanitasiOraId, DateTime datum, int fileTipusId, bool isTanuloLathato)
|
|
{
|
|
Dal.CustomConnection.Run(ConnectionType, (h) =>
|
|
{
|
|
var dal = h.OraFile();
|
|
var oraFile = dal.Get();
|
|
oraFile.DKT_FileId = DKT_FileId;
|
|
oraFile.OraDatum = datum;
|
|
oraFile.OraFileTipusId = fileTipusId;
|
|
oraFile.IsTanuloLathato = isTanuloLathato;
|
|
oraFile.IntezmenyId = IntezmenyId;
|
|
oraFile.TanevId = TanevId;
|
|
oraFile.AlkalmazottId = FelhasznaloId;
|
|
|
|
if (orarendiOraId.HasValue)
|
|
{
|
|
var orarendiOra = h.OrarendiOra().Get(orarendiOraId.Value);
|
|
oraFile.OrarendiOraId = orarendiOraId.Value;
|
|
oraFile.TantargyId = orarendiOra.TantargyId;
|
|
oraFile.OsztalyCsoportId = orarendiOra.OsztalyCsoportId;
|
|
|
|
}
|
|
else if (tanitasiOraId.HasValue)
|
|
{
|
|
var tanitasiOra = h.TanitasiOra().Get(tanitasiOraId.Value);
|
|
oraFile.TantargyId = tanitasiOra.TantargyId;
|
|
oraFile.OsztalyCsoportId = tanitasiOra.OsztalyCsoportId;
|
|
oraFile.TanitasiOraId = tanitasiOraId.Value;
|
|
}
|
|
else
|
|
{
|
|
throw new BlException(BlExceptionType.ElvartErtekNemTalalhato);
|
|
}
|
|
|
|
dal.Insert(oraFile);
|
|
});
|
|
}
|
|
|
|
public void DeleteOraFile(int oraFileId)
|
|
{
|
|
Dal.CustomConnection.Run(ConnectionType, (h) =>
|
|
{
|
|
var entity = h.OraFile().Get(oraFileId);
|
|
IDKT_File csatolmany = h.DKT_FileDAL().Get(entity.DKT_FileId);
|
|
|
|
if (!fileServiceHelper.Delete(IntezmenyAzonosito, new FileDeleteRequest(csatolmany.Utvonal, csatolmany.FileGuid.Value)))
|
|
{
|
|
throw new BlException(ErrorResource.FajlTorleseSikertelen);
|
|
}
|
|
h.OraFile().Delete(entity);
|
|
h.DKT_FileDAL().Delete(entity.DKT_FileId);
|
|
});
|
|
}
|
|
|
|
public DataSet GetOraFilesByDateRange(DateTime start, DateTime end, int? oraFileTipus)
|
|
{
|
|
return Dal.CustomConnection.Run(ConnectionType, h =>
|
|
{
|
|
return h.OraFile().GetOraFilesByDateRange(start, end, oraFileTipus);
|
|
});
|
|
}
|
|
}
|
|
}
|