77 lines
3.1 KiB
C#
77 lines
3.1 KiB
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using Kreta.BusinessLogic.Classes;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Areas.Intezmeny.Models;
|
|
using ModelStateDictionary = System.Web.Http.ModelBinding.ModelStateDictionary;
|
|
|
|
namespace Kreta.Web.Areas.Adatszolgaltatasok.Models
|
|
{
|
|
public class MeroallasModel
|
|
{
|
|
public int? Id { get; set; }
|
|
public int MerohelyId { get; set; }
|
|
|
|
[KretaRequired(typeof(KozmuAdatszolgaltatasResource), nameof(KozmuAdatszolgaltatasResource.MeroallasMegadasaKotelezo))]
|
|
[Display(Name = nameof(KozmuAdatszolgaltatasResource.Meroallas), ResourceType = typeof(KozmuAdatszolgaltatasResource))]
|
|
[KretaRange(0.00, Core.Constants.MinMaxValues.MerohelyMaxValue, StringResourcesId = 4178)] //Az érték nem esik a megengedett tartományba
|
|
public double? Meroallas { get; set; }
|
|
|
|
[Display(Name = nameof(KozmuAdatszolgaltatasResource.LeolvasasDatuma), ResourceType = typeof(KozmuAdatszolgaltatasResource))]
|
|
[KretaRequired(typeof(KozmuAdatszolgaltatasResource), nameof(KozmuAdatszolgaltatasResource.MeroallasLeolvasasDatumaNakMegadasaKotelezo))]
|
|
public DateTime? LeolvasasDatuma { get; set; }
|
|
|
|
public int? PictureId { get; set; }
|
|
|
|
public UploadedFile MeroallasKep { get; set; }
|
|
|
|
public bool IsDeleteImage { get; set; }
|
|
|
|
public MeroallasCO ConvertToCo()
|
|
{
|
|
var co = new MeroallasCO();
|
|
co.MeroallasKep = new MeroallasUploadedFileCO();
|
|
co.Id = Id;
|
|
co.MerohelyId = MerohelyId;
|
|
co.MeroallasErtek = Meroallas;
|
|
co.LeolvasasDatuma = LeolvasasDatuma;
|
|
co.IsDeleteImage = IsDeleteImage;
|
|
co.KepId = PictureId;
|
|
|
|
if (MeroallasKep != null)
|
|
{
|
|
co.MeroallasKep.ContentAsBase64EncodedString = MeroallasKep.ContentAsBase64EncodedString;
|
|
co.MeroallasKep.Name = MeroallasKep.Name;
|
|
}
|
|
|
|
return co;
|
|
}
|
|
|
|
public ModelStateDictionary Validate()
|
|
{
|
|
var modelStateDictionary = new ModelStateDictionary();
|
|
|
|
if (LeolvasasDatuma.HasValue)
|
|
{
|
|
var mindate = new DateTime(1900, 1, 1);
|
|
if (LeolvasasDatuma.Value < mindate || LeolvasasDatuma.Value > DateTime.Today)
|
|
{
|
|
modelStateDictionary.AddModelError(nameof(LeolvasasDatuma), string.Format(KozmuAdatszolgaltatasResource.ALeolvasasDatumaCsakKozeEshet, mindate.ToString("yyyy. MM. dd."), DateTime.Today.ToString("yyyy. MM. dd.")));
|
|
}
|
|
}
|
|
if (Meroallas.HasValue)
|
|
{
|
|
if (Meroallas.Value < 0 || Meroallas.Value > Kreta.Core.Constants.MinMaxValues.MerohelyMaxValue)
|
|
{
|
|
modelStateDictionary.AddModelError(nameof(Meroallas), string.Format(KozmuAdatszolgaltatasResource.AMeroallasCsakKozeEshet, "0", Core.Constants.MinMaxValues.MerohelyMaxValue.ToString()));
|
|
}
|
|
|
|
}
|
|
|
|
return modelStateDictionary;
|
|
}
|
|
|
|
}
|
|
}
|
|
|