Добавьте файлы проекта.
This commit is contained in:
33
Models/Contact.cs
Normal file
33
Models/Contact.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace ContactsApp
|
||||
{
|
||||
public class Contact
|
||||
{
|
||||
public Guid Id { get; }
|
||||
public string Name { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
|
||||
public Contact(string name, string? email, string phone)
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
Name = name;
|
||||
|
||||
try
|
||||
{
|
||||
var addr = new MailAddress(email);
|
||||
Email = email;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Invalid email");
|
||||
}
|
||||
|
||||
Phone = phone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user