init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
210
Kreta.BusinessLogic/Helpers/JelszoModositasLinkHelper.cs
Normal file
210
Kreta.BusinessLogic/Helpers/JelszoModositasLinkHelper.cs
Normal file
|
@ -0,0 +1,210 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kreta.BusinessLogic.Exceptions;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.ConnectionType;
|
||||
using Kreta.DataAccess.Interfaces;
|
||||
using Kreta.DataAccessManual;
|
||||
using Kreta.DataAccessManual.Interfaces;
|
||||
using Kreta.DataAccessManual.Util;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.BusinessLogic.Helpers
|
||||
{
|
||||
public class JelszoModositasLinkHelper : LogicBase
|
||||
{
|
||||
public JelszoModositasLinkHelper(IConnectionType connectionType) : base(connectionType) { }
|
||||
|
||||
public void BeazonositottGondvilseoLinkGeneralasEsKuldes(int felhasznaloId, int? gondviseloId, string emailCim, string message, Guid? emailGuid)
|
||||
{
|
||||
Dal.CustomConnection.Run(ConnectionType, h => LinkGeneralasEsKuldes(h, felhasznaloId, gondviseloId, emailCim, true, message, emailGuid));
|
||||
}
|
||||
|
||||
public void UjCsokkentettGondviseloLinkGeneralasEsKuldes(GondviseloJelszoIgenyloCo co, int tanuloId, int tanevId, int intezmenyId, IntezmenyNevCimCo intezmenyCo)
|
||||
{
|
||||
Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var gondviseloDal = h.Gondviselo();
|
||||
var cimDal = h.Cim();
|
||||
var emailDal = h.Email();
|
||||
|
||||
var gondviselo = gondviseloDal.Get();
|
||||
gondviselo.Nev = co.GondviseloNev;
|
||||
gondviselo.RokonsagFoka = co.RokonsagiFok.Value;
|
||||
gondviselo.TanuloId = tanuloId;
|
||||
gondviselo.IsCsokkentettGondviselo = true;
|
||||
gondviselo.IntezmenyId = intezmenyId;
|
||||
gondviselo.TanevId = tanevId;
|
||||
|
||||
gondviseloDal.Insert(gondviselo);
|
||||
|
||||
var cim = cimDal.Get();
|
||||
cim.FelhasznaloId = tanuloId;
|
||||
cim.GondviseloId = gondviselo.ID;
|
||||
cim.Ajto = co.Ajto;
|
||||
cim.CimTipusa = co.CimTipus ?? (int)CimTipusEnum.allando_lakcim;
|
||||
cim.Emelet = co.Emelet;
|
||||
cim.Hazszam = co.Hazszam;
|
||||
cim.IranyitoSzam = co.Iranyitoszam;
|
||||
cim.Kozterulet = co.KozteruletNev;
|
||||
cim.KozteruletJellegeNev = co.KozteruletTipusNev;
|
||||
cim.Orszag = co.Orszag.Value;
|
||||
cim.Varos = co.HelysegNev;
|
||||
cim.IntezmenyId = intezmenyId;
|
||||
cim.TanevId = tanevId;
|
||||
|
||||
cimDal.Insert(cim);
|
||||
|
||||
var email = emailDal.Get();
|
||||
email.FelhasznaloId = tanuloId;
|
||||
email.GondviseloId = gondviselo.ID;
|
||||
email.EmailCim = co.GondviseloEmail;
|
||||
email.EmailTipusa = co.EmailTipusId ?? -1;
|
||||
email.IntezmenyId = intezmenyId;
|
||||
email.TanevId = tanevId;
|
||||
email.Alapertelmezett = true;
|
||||
|
||||
Guid emailGuid = emailDal.Insert(email).Guid;
|
||||
|
||||
var message = string.Format(EmailResource.GondviseloCsokkentettBelepesiAdatoErtesitesEmail, co.GondviseloNev, CommonUtils.GetIntezmenyUrl(intezmenyCo.IntezmenyAzonosito), intezmenyCo.Nev, intezmenyCo.IntezmenyCim, "{0}");
|
||||
|
||||
LinkGeneralasEsKuldes(h, tanuloId, gondviselo.ID, co.GondviseloEmail, true, message, emailGuid);
|
||||
});
|
||||
}
|
||||
|
||||
public void FelhasznaloBelepesLinkGeneralasEsKuldes(int felhasznaloId, int? gondviseloId, string emailCim, string message, Guid emailGuid)
|
||||
{
|
||||
Dal.CustomConnection.Run(ConnectionType, h => LinkGeneralasEsKuldes(h, felhasznaloId, gondviseloId, emailCim, true, message, emailGuid));
|
||||
}
|
||||
|
||||
//nincs hasznlava jelenleg!
|
||||
public string JelszoValtoztatoLinkGeneralas(int felhasznaloId, int? gondviseloId)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h => LinkGeneralasEsKuldes(h, felhasznaloId, gondviseloId, null, false, null, null));
|
||||
}
|
||||
|
||||
public void JelszoValtoztatoLinkGeneralasEsKuldes(string felhasznaloNev, string emailCim)
|
||||
{
|
||||
felhasznaloNev = felhasznaloNev.Trim().ToLower();
|
||||
emailCim = emailCim.Trim().ToLower();
|
||||
|
||||
Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var felhasznaloBelepesCo = new FelhasznaloBelepesHelper(new DalHandlerConnectionType(ConnectionType, h)).Get(felhasznaloNev);
|
||||
if (felhasznaloBelepesCo != null)
|
||||
{
|
||||
if (felhasznaloBelepesCo.GondviseloId.IsEntityId())
|
||||
{
|
||||
var gondviselo = h.Gondviselo().Get(felhasznaloBelepesCo.GondviseloId.Value);
|
||||
IEmail email = gondviselo?.Email?.SingleOrDefault(x => !x.Torolt && !x.IsHibasanMegadva);
|
||||
var gondviseloEmailCim = email?.EmailCim;
|
||||
Guid? gondviseloEmailGuid = email?.Guid;
|
||||
if (!string.IsNullOrWhiteSpace(gondviseloEmailCim) && gondviseloEmailCim.ToLower().Equals(emailCim))
|
||||
{
|
||||
var intezmenyCo = new IntezmenyHelper(new DalHandlerConnectionType(ConnectionType, h)).GetAktivIntezmenyNevCim();
|
||||
var message = string.Format(EmailResource.ElfejeltettJelszoLinkEmail, EmailResource.Tisztelt, gondviselo.Nev, CommonUtils.GetIntezmenyUrl(intezmenyCo.IntezmenyAzonosito), intezmenyCo.Nev, intezmenyCo.IntezmenyCim, "{0}");
|
||||
|
||||
LinkGeneralasEsKuldes(h, felhasznaloBelepesCo.FelhasznaloId, felhasznaloBelepesCo.GondviseloId, gondviseloEmailCim, false, message, gondviseloEmailGuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new KretaJelszoModositasException(ErrorResource.AMegadottFelhasznalonevhezNincsRogzitveEmailCimVagyRosszEmailCimetAdottMeg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IEnumerable<IEmail> email = null;
|
||||
ITanulo tanulo = null;
|
||||
try
|
||||
{
|
||||
tanulo = h.Tanulo().Get(felhasznaloBelepesCo.FelhasznaloId);
|
||||
}
|
||||
catch (EntityNotFoundException)
|
||||
{
|
||||
if (h.Alkalmazott().IsAlkalmazott(felhasznaloBelepesCo.FelhasznaloId, TanevId))
|
||||
{
|
||||
throw new KretaJelszoModositasException(ErrorResource.AJelszoEmlekeztetoPedagogusokSzamaraNemElerhetoKerjukKeresseFelAKretaRendszerAdminisztratorat);
|
||||
}
|
||||
}
|
||||
|
||||
email = tanulo?.Email?.Where(x => !x.Torolt && !x.IsHibasanMegadva);
|
||||
var tanuloEmailCim = string.Empty;
|
||||
Guid? tanuloEmailGuid = null;
|
||||
if (email != null)
|
||||
{
|
||||
foreach (var item in email)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(item.EmailCim) && item.EmailCim.ToLower().Equals(emailCim))
|
||||
{
|
||||
tanuloEmailCim = item.EmailCim;
|
||||
tanuloEmailGuid = item.Guid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tanuloEmailCim))
|
||||
{
|
||||
var intezmenyCo = new IntezmenyHelper(new DalHandlerConnectionType(ConnectionType, h)).GetAktivIntezmenyNevCim();
|
||||
var message = string.Format(EmailResource.ElfejeltettJelszoLinkEmail, EmailResource.Kedves, tanulo.NyomtatasiNev, CommonUtils.GetIntezmenyUrl(intezmenyCo.IntezmenyAzonosito), intezmenyCo.Nev, intezmenyCo.IntezmenyCim, "{0}");
|
||||
|
||||
LinkGeneralasEsKuldes(h, felhasznaloBelepesCo.FelhasznaloId, null, tanuloEmailCim, false, message, tanuloEmailGuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new KretaJelszoModositasException(ErrorResource.AMegadottFelhasznalonevhezNincsRogzitveEmailCimVagyRosszEmailCimetAdottMeg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new KretaJelszoModositasException(ErrorResource.AMegadottFelhasznalonevNemSzerepelAKRETARendszerben);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private string LinkGeneralasEsKuldes(IDalHandler h, int felhasznaloId, int? gondviseloId, string emailCim, bool isSzuletesiDatumValidacio, string message, Guid? emailGuid = null)
|
||||
{
|
||||
var isTanulo = new TanuloHelper(new DalHandlerConnectionType(ConnectionType, h)).IsTanulo(felhasznaloId);
|
||||
|
||||
if (!isTanulo)
|
||||
{
|
||||
throw new KretaJelszoModositasException(string.Empty);
|
||||
}
|
||||
|
||||
var dal = h.JelszoModositasLinkDal();
|
||||
dal.DeleteIfExists(felhasznaloId, gondviseloId);
|
||||
|
||||
var entity = dal.Get();
|
||||
|
||||
entity.Azonosito = Guid.NewGuid().ToString();
|
||||
entity.FelhasznaloId = felhasznaloId;
|
||||
|
||||
if (gondviseloId.HasValue)
|
||||
{
|
||||
entity.GondviseloId = gondviseloId.Value;
|
||||
}
|
||||
|
||||
entity.IntezmenyId = CommonUtils.GetIntezmenyId(felhasznaloId);
|
||||
entity.IsSzuletesiDatumValidacio = isSzuletesiDatumValidacio;
|
||||
entity.LetrehozasDatuma = DateTime.Now;
|
||||
entity.ProbalkozasokSzama = 0;
|
||||
entity.TanevId = TanevId;
|
||||
|
||||
dal.Insert(entity);
|
||||
|
||||
var link = string.Format(AdminisztracioResource.Link, IntezmenyAzonosito, entity.Azonosito);
|
||||
if (!string.IsNullOrWhiteSpace(emailCim))
|
||||
{
|
||||
new UzenetekHelper(new DalHandlerConnectionType(ConnectionType, h)).EmailKuldes(string.Format(message, link), CommonResource.Ertesites, emailCim, emailGuid.HasValue ? emailGuid : null);
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue