kreta/KretaWeb/Areas/Alkalmazott/Helpers/AlkalmazottLogic.cs
2024-03-13 00:33:46 +01:00

33 lines
1.4 KiB
C#

using System;
using System.Linq;
using System.Web.Http.ModelBinding;
using Kreta.BusinessLogic.Helpers;
using Kreta.Resources;
using Kreta.Web.Helpers;
using Kreta.Web.Models;
namespace Kreta.Web.Areas.Alkalmazott.Helpers
{
public class AlkalmazottLogic
{
public static void AlkalmazottEmailCustomValidation(ModelStateDictionary modelState, CimElerhetosegModel model)
{
var alkalmazottHelper = new AlkalmazottHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var emails = alkalmazottHelper.GetEmailsCoList(model.FelhasznaloId).Where(x => x.ID != model.Id).Select(x => x.EmailCim);
if (emails.Contains(model.Emailcim_Input))
{
modelState.AddModelError(nameof(model.Emailcim_Input), ErrorResource.AMegadottEmailcimMarRogzitveVan);
}
}
public static void AlkalmazottTelefonCustomValidation(ModelStateDictionary modelState, CimElerhetosegModel model)
{
var alkalmazottHelper = new AlkalmazottHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var phones = alkalmazottHelper.GetPhonesCoList(model.FelhasznaloId).Where(x => x.ID != model.Id).Select(x => x.Telefonszam);
if (phones.Contains(model.Telefon))
{
modelState.AddModelError(nameof(model.Telefon), ErrorResource.AMegadottTelefonszamMarRogzitveVan);
}
}
}
}