init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using Kreta.BusinessLogic.Classes.MobileApi.Common.Co;
|
||||
using Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Post.OpenBoard;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Interfaces;
|
||||
using Kreta.Core.ConnectionType;
|
||||
using Kreta.Core.Validation.Exceptions;
|
||||
using Kreta.DataAccessManual.Interfaces;
|
||||
using Kreta.DataAccessManual.Util;
|
||||
using Kreta.Enums;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.SubqueriesRepo.Post
|
||||
{
|
||||
public static class FeltoltottFajlPostSubqueries
|
||||
{
|
||||
public static FeltoltottFajlResponseCo CreateFajlFeltoltes(IDalHandler h, IFileServiceHelper fileServiceHelper, DefaultConnectionParameters defaultConnectionParameters, FeltoltottFajlRequestCo request)
|
||||
{
|
||||
var response = new FeltoltottFajlResponseCo();
|
||||
if (request.TanitasiOraId.HasValue && request.OrarendiOraId.HasValue)
|
||||
{
|
||||
response.Exception = new ValidationException("Hibás kérelem!");
|
||||
return response;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IConnectionType connection = new DalHandlerConnectionType(new MobileConnectionType(defaultConnectionParameters.FelhasznaloId, defaultConnectionParameters.IntezmenyId, defaultConnectionParameters.IntezmenyAzonosito, defaultConnectionParameters.TanevId), h);
|
||||
var openBoardHelper = new OpenBoardHelper(new DalHandlerConnectionType(new MobileConnectionType(defaultConnectionParameters.FelhasznaloId, defaultConnectionParameters.IntezmenyId, defaultConnectionParameters.IntezmenyAzonosito, defaultConnectionParameters.TanevId), h), fileServiceHelper);
|
||||
var dktFileHelper = new DktFileHelper(new DalHandlerConnectionType(new MobileConnectionType(defaultConnectionParameters.FelhasznaloId, defaultConnectionParameters.IntezmenyId, defaultConnectionParameters.IntezmenyAzonosito, defaultConnectionParameters.TanevId), h), fileServiceHelper);
|
||||
|
||||
int feltoltottFajlokSzama = openBoardHelper.GetFeltoltottFajlokSzama(DateTime.Now, request.OrarendiOraId, request.TanitasiOraId);
|
||||
int feltolthetoFajlokSzama = Constant.FeltolthetoFajlokMaxSzama - feltoltottFajlokSzama;
|
||||
|
||||
if (feltolthetoFajlokSzama < 1)
|
||||
{
|
||||
throw new ValidationException("Nem tölthető fel a fájl, mert elérte a maximális feltöltési limitet ehhez az órához!");
|
||||
}
|
||||
|
||||
DateTime ido = DateTime.Now;
|
||||
int sorszam = feltoltottFajlokSzama + 1;
|
||||
string fileName = $"Kep_{sorszam}_{ido.ToString(Constant.DateTimeFormat)}";
|
||||
string contentType = "image/jpeg";
|
||||
|
||||
var intezmenyGuid = new IntezmenyHelper(connection).GetIntezmenyiAdatok().IntezmenyGuid;
|
||||
|
||||
var path = $"OpenBoard/{intezmenyGuid}/{defaultConnectionParameters.TanevId}";
|
||||
if (request.TanitasiOraId.HasValue)
|
||||
{
|
||||
path += $"/TanitasiOra/{request.TanitasiOraId.Value}";
|
||||
}
|
||||
else if (request.OrarendiOraId.HasValue)
|
||||
{
|
||||
path += $"/OrarendiOra/{request.OrarendiOraId.Value}";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ValidationException("Nem tartozhat Órarendi órához és Tanítási órához is a kép! Csak az egyik legyen megadva!");
|
||||
}
|
||||
|
||||
var fileId = dktFileHelper.UploadFile(string.Concat(fileName, ".jpeg"), Convert.FromBase64String(request.ContentAsBase64EncodedString.Replace("data:image/jpeg;base64,", "")), contentType, path);
|
||||
|
||||
var oraFileHelper = new OraFileHelper(connection);
|
||||
oraFileHelper.InsertFileToOraFile(fileId, request.OrarendiOraId, request.TanitasiOraId, ido.Date, (int)OraFileTipusEnum.openboard, true);
|
||||
|
||||
response.FeltolthetoFajlokSzama = feltolthetoFajlokSzama - 1;
|
||||
}
|
||||
catch (ValidationException e)
|
||||
{
|
||||
response.Exception = e;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue