init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
79
KretaWeb/Classes/Utils.cs
Normal file
79
KretaWeb/Classes/Utils.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tanulo.Models;
|
||||
using Kreta.Web.Configuration;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Classes
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static string GetExcelTemplateFilePath(string fileName)
|
||||
{
|
||||
return GetServerFilePath(Constants.ImportExport.ExcelTemplateDirectory, fileName);
|
||||
}
|
||||
|
||||
public static string GetExcelTemplateImportExportFilePath(string fileName)
|
||||
{
|
||||
return GetServerFilePath(Constants.ImportExport.ExcelTemplateImportExportDirectory, fileName);
|
||||
}
|
||||
|
||||
public static string GetServerFilePath(string directory, string fileName)
|
||||
{
|
||||
string directoryPath = HttpContext.Current.Server.MapPath(directory);
|
||||
var directoryInfo = new DirectoryInfo(directoryPath);
|
||||
FileInfo fileInfo = directoryInfo.GetFiles().SingleOrDefault(x => x.Name.Equals(fileName, StringComparison.InvariantCultureIgnoreCase));
|
||||
var fullName = fileInfo?.FullName;
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public static void TelefonSzamValidation(System.Web.Http.ModelBinding.ModelStateDictionary modelState, string telefonszam, int? telefonTipus, TelefonszamTulajdonosEnum telefonszamTulajdonos)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(telefonszam) && telefonTipus == null)
|
||||
{
|
||||
modelState.AddModelError("CimElerhetosegModel.TelefonTipus", ErrorResource.Telefon0TipusKotelezo.Replace("{0}", telefonszamTulajdonos.GetDisplayName(ClaimData.SelectedTanevID.Value)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void TajSzamValidation(System.Web.Http.ModelBinding.ModelStateDictionary modelState, string modelKey, string tajSzam)
|
||||
{
|
||||
var errorMessages = CommonUtils.TajSzamValidation(tajSzam);
|
||||
foreach (var errorMessage in errorMessages)
|
||||
{
|
||||
modelState.AddModelError(modelKey, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetTanuloEletkor(TanuloModel tanuloModel)
|
||||
{
|
||||
TimeSpan span = DateTime.Now - tanuloModel.TanuloAlapAdatModel.SzuletesiIdo.Value;
|
||||
int tanuloEletkor = (DateTime.MinValue + span).Year - 1;
|
||||
|
||||
return tanuloEletkor;
|
||||
}
|
||||
|
||||
public static string GetAuthenticationTokenRedirectUrl(string baseUrl, string key)
|
||||
{
|
||||
var idpConfiguration = DependencyResolver.Current.GetService<IIdpConfiguration>();
|
||||
|
||||
string redirectUrl = idpConfiguration.LoginEnabled ? baseUrl : new AuthenticationHelper(ConnectionTypeExtensions.GetSessionConnectionType()).CreateUrl(baseUrl, key, ClaimData.IntezmenyiDictionaryEnvironmentName);
|
||||
|
||||
return redirectUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visszaadja a másik "lényeges" tanév id-t.
|
||||
/// Következő tanév esetén az aktuálisat, aktuális tanév esetén a következő tanévét, ha létezik.
|
||||
/// </summary>
|
||||
public static int? GetAnotherYearId() => ClaimData.IsKovTanev ? ClaimData.AktivTanevID : (ClaimData.IsActivTanev && ClaimData.KovTanevID.HasValue ? ClaimData.KovTanevID : null);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue