Guarantor: Contracts + DatabaseImplementation partly.
This commit is contained in:
parent
ef018c1331
commit
377a803ac1
@ -12,8 +12,8 @@ namespace ComputerStoreContracts.BindingModels
|
|||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public string Username { get; set; } = string.Empty;
|
public string Username { get; set; } = string.Empty;
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
public string FirstName { get; set; } = string.Empty;
|
public string? FirstName { get; set; } = string.Empty;
|
||||||
public string LastName { get; set; } = string.Empty;
|
public string? LastName { get; set; } = string.Empty;
|
||||||
public string MiddleName { get; set; } = string.Empty;
|
public string? MiddleName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,13 @@ namespace ComputerStoreContracts.ViewModels
|
|||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Employee's first name")]
|
[DisplayName("Employee's first name")]
|
||||||
public string FirstName { get; set; } = string.Empty;
|
public string? FirstName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Employee's last name")]
|
[DisplayName("Employee's last name")]
|
||||||
public string LastName { get; set; } = string.Empty;
|
public string? LastName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Employee's middle name")]
|
[DisplayName("Employee's middle name")]
|
||||||
public string MiddleName { get; set; } = string.Empty;
|
public string? MiddleName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ namespace ComputerStoreDataModels.Models
|
|||||||
{
|
{
|
||||||
string Username { get; }
|
string Username { get; }
|
||||||
string Password { get; }
|
string Password { get; }
|
||||||
string FirstName { get; }
|
string? FirstName { get; }
|
||||||
string LastName { get; }
|
string? LastName { get; }
|
||||||
string MiddleName { get; }
|
string? MiddleName { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,9 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ComputerStoreContracts\ComputerStoreContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\ComputerStoreDataModels\ComputerStoreDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
66
ComputerStoreDatabaseImplement/Models/Employee.cs
Normal file
66
ComputerStoreDatabaseImplement/Models/Employee.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using ComputerStoreDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ComputerStoreContracts.BindingModels;
|
||||||
|
using ComputerStoreContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace ComputerStoreDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Employee : IEmployeeModel
|
||||||
|
{
|
||||||
|
public int ID { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Username { get; private set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string? FirstName { get; private set; } = string.Empty;
|
||||||
|
public string? LastName { get; private set; } = string.Empty;
|
||||||
|
public string? MiddleName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
//[ForeignKey("EmployeeID")]
|
||||||
|
//public virtual List<PC> PCs { get; set; } = new();
|
||||||
|
|
||||||
|
public static Employee? Create(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Employee()
|
||||||
|
{
|
||||||
|
ID = model.ID,
|
||||||
|
Username = model.Username,
|
||||||
|
Password = model.Password,
|
||||||
|
FirstName = model.FirstName,
|
||||||
|
LastName = model.LastName,
|
||||||
|
MiddleName = model.MiddleName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null) { return; }
|
||||||
|
Username = model.Username;
|
||||||
|
Password = model.Password;
|
||||||
|
FirstName = model.FirstName;
|
||||||
|
LastName = model.LastName;
|
||||||
|
MiddleName = model.MiddleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
ID = ID,
|
||||||
|
Username = Username,
|
||||||
|
Password = Password,
|
||||||
|
FirstName = FirstName,
|
||||||
|
LastName = LastName,
|
||||||
|
MiddleName = MiddleName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user