-
Notifications
You must be signed in to change notification settings - Fork 1
/
RegistrationViewModel.cs
47 lines (44 loc) · 1.71 KB
/
RegistrationViewModel.cs
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
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Mvvm.POCO;
using RegistrationForm.DataModel;
using System;
namespace RegistrationForm.ViewModel {
[POCOViewModel]
public class RegistrationViewModel {
public static RegistrationViewModel Create() {
return ViewModelSource.Create(() => new RegistrationViewModel());
}
protected RegistrationViewModel() {
MinBirthday = new DateTime(DateTime.Now.Year - 100, 12, 31);
MaxBirthday = new DateTime(DateTime.Now.Year - 1, 12, 31);
if(this.IsInDesignMode())
InitializeInDesignMode();
else InitializeInRuntime();
}
void InitializeInDesignMode() {
FirstName = "John";
LastName = "Smith";
Email = "[email protected]";
Password = "Password";
ConfirmPassword = "Password";
Birthday = new DateTime(1980, 1, 1);
Gender = 1;
}
void InitializeInRuntime() {
Birthday = null;
Gender = -1;
}
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual string Email { get; set; }
public virtual string Password { get; set; }
public virtual string ConfirmPassword { get; set; }
public virtual DateTime? Birthday { get; set; }
public virtual DateTime MinBirthday { get; set; }
public virtual DateTime MaxBirthday { get; set; }
public virtual int Gender { get; set; }
public void AddEmployee() {
EmployeesModelHelper.AddNewEmployee(FirstName, LastName, Email, Password, Birthday.Value, Gender);
}
}
}