blob: 26f0329b016fb823786d2cbfbe3890517149f71b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SimpleValidator.Extensions;
namespace Tango.BL.Entities
{
public partial class Contact
{
protected override void RaisePropertyChanged(string propName)
{
base.RaisePropertyChanged(propName);
if (propName == nameof(FirstName) || propName == nameof(LastName))
{
FixNames();
}
}
private void FixNames()
{
if (_firstname != null)
{
_firstname = _firstname.Trim();
}
if (_lastname != null)
{
_lastname = _lastname.Trim();
}
FullName = FirstName + " " + LastName;
}
public override void Validate(ObservablesContext context)
{
base.Validate(context);
if (FirstName.IsNullOrWhiteSpace() || LastName.IsNullOrWhiteSpace())
{
throw new ArgumentException("Contact first name and last name was not provided.");
}
if (!Email.IsEmail())
{
throw new ArgumentException("Invalid contact email format.");
}
}
}
}
|