using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace DiplomovaPrace.Contracts.Customer.Addresses
{
	public class DeliveryAddressDto : IValidatableObject
	{
        public int? ID { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string PhoneNumber { get; set; }

        public string City { get; set; }

        public string Street { get; set; }

        public string ZipCode { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (ID is null && FirstName is not null)
            {
                if (string.IsNullOrWhiteSpace(FirstName))
                {
                    yield return new ValidationResult($"FirstName is required.", new[] { nameof(FirstName) });
                }
                if (string.IsNullOrWhiteSpace(LastName))
                {
                    yield return new ValidationResult($"LastName is required.", new[] { nameof(LastName) });
                }
                if (string.IsNullOrWhiteSpace(PhoneNumber))
                {
                    yield return new ValidationResult($"PhoneNumber is required.", new[] { nameof(PhoneNumber) });
                }
                if (string.IsNullOrWhiteSpace(City))
                {
                    yield return new ValidationResult($"City is required.", new[] { nameof(City) });
                }
                if (string.IsNullOrWhiteSpace(Street))
                {
                    yield return new ValidationResult($"Street is required.", new[] { nameof(Street) });
                }
                if (string.IsNullOrWhiteSpace(ZipCode))
                {
                    yield return new ValidationResult($"ZipCode is required.", new[] { nameof(ZipCode) });
                }
            }
        }
    }
}
