Wonky.Client/Wonky.Entity/DTO/CompanyDto.cs

101 lines
3.7 KiB
C#
Raw Normal View History

// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
2022-05-31 19:07:39 +02:00
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2022-05-31 19:07:39 +02:00
// GNU Affero General Public License for more details.
//
2022-05-31 19:07:39 +02:00
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
2023-05-21 08:23:47 +02:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
2023-03-19 10:05:44 +01:00
public class CompanyDto
{
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
2022-12-07 14:58:03 +01:00
public string Account { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
2022-12-07 14:58:03 +01:00
public string Address1 { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")]
2022-12-07 14:58:03 +01:00
public string Address2 { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
2022-12-07 14:58:03 +01:00
public string Attention { get; set; } = "";
public string BcId { get; set; } = "";
2022-12-07 14:58:03 +01:00
public string Blocked { get; set; } = "";
2022-12-07 14:58:03 +01:00
[Required(ErrorMessage = "Bynavn skal udfyldes")]
[MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")]
public string City { get; set; } = "";
2022-12-07 14:58:03 +01:00
public string CompanyId { get; set; } = "";
public string CountryCode { get; set; } = "";
public string CrmNotes { get; set; } = "";
2023-04-13 18:40:02 +02:00
public string EanNumber { get; set; } = "";
[MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")]
public string Email { get; set; } = "";
2023-04-28 14:00:48 +02:00
[MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")]
public string Fax { get; set; } = "";
2022-12-07 14:58:03 +01:00
public int HasFolded { get; set; }
public string HistorySync { get; set; } = "";
[Range(1, 52, ErrorMessage = "Angiv interval mellem 1 og 52 uger")]
public int Interval { get; set; } = 8;
2022-12-07 14:58:03 +01:00
public int IsHidden { get; set; }
2022-07-01 10:02:29 +02:00
public string LastVisit { get; set; } = "2010-01-01";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
2022-12-07 14:58:03 +01:00
public string Mobile { get; set; } = "";
2022-12-07 14:58:03 +01:00
[Required(ErrorMessage = "Navn skal udfyldes")]
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
public string Name { get; set; } = "";
2022-07-01 10:02:29 +02:00
public string NextVisit { get; set; } = "2010-01-01";
2022-12-07 14:58:03 +01:00
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
public string Note { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
2022-12-07 14:58:03 +01:00
public string Phone { get; set; } = "";
public string SalesRep { get; set; } = "";
2022-07-01 10:02:29 +02:00
public string SalesRepId { get; set; } = "";
[Required(ErrorMessage = "Segment skal vælges - AUTO eller INDUSTRI")]
2023-04-18 16:52:09 +02:00
public string Segment { get; set; } = "";
2022-05-31 19:07:39 +02:00
public int ValidVat { get; set; }
2022-12-07 14:58:03 +01:00
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
public string VatNumber { get; set; } = "";
2022-07-01 10:02:29 +02:00
2022-12-07 14:58:03 +01:00
[Required(ErrorMessage = "Postnummer skal udfyldes")]
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
public string ZipCode { get; set; } = "";
2022-08-30 15:21:39 +02:00
public virtual bool ValidDateSpan()
2022-06-08 18:52:00 +02:00
{
var notAllowed = new List<string> { "2010-01-01", "1970-01-01", "0001-01-01" };
2022-06-08 18:52:00 +02:00
if (notAllowed.Contains(LastVisit) || notAllowed.Contains(NextVisit))
return false;
return DateTime.Parse(LastVisit) < DateTime.Parse(NextVisit);
}
}