using Core.Abstractions; using Core.Abstractions.Models; using DomainObjects; using Core.Enumerations; using Extensions; using System.ComponentModel.DataAnnotations; using DomainObjects.Enumerations; namespace WeatherForecast.Models.Abstractions.PostItem.Requests { /// /// /// public class MediaAttachmentRequestModel : RequestModelBase { /// /// /// public string? Src { get; set; } /// /// /// public string? MediaType { get; set; } /// /// /// public List? L10n { get; set; } /// /// /// /// /// public override MediaAttachment ToDomainObject() { return new MediaAttachment { Src = Src, MediaType = Enumeration.FromDisplayName(MediaType), L10n = L10n.Select(x => x.ToDomainObject()).ToList() }; } /// /// /// /// /// /// public override IEnumerable Validate(ValidationContext validationContext) { if (string.IsNullOrWhiteSpace(Src)) yield return new ValidationResult($"{nameof(Src)} {Errors.NullOrWhiteSpace}"); if (string.IsNullOrWhiteSpace(MediaType)) yield return new ValidationResult($"{nameof(MediaType)} {Errors.NullOrWhiteSpace}"); if (L10n.IsNullOrEmpty()) yield return new ValidationResult($"{nameof(L10n)} {Errors.NullOrEmpty}"); } } }