Implemented propertychanged pattern to connect UI with entity
This commit is contained in:
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,44 +1,204 @@
|
||||
namespace AdventureWorks.EntityLayer.EntityClasses
|
||||
using Common.Library;
|
||||
|
||||
namespace AdventureWorks.EntityLayer.EntityClasses;
|
||||
|
||||
public class User : EntityBase
|
||||
{
|
||||
public class User
|
||||
public User()
|
||||
{
|
||||
public User()
|
||||
{
|
||||
LoginId = string.Empty;
|
||||
FirstName = string.Empty;
|
||||
LastName = string.Empty;
|
||||
Email = string.Empty;
|
||||
Password = string.Empty;
|
||||
Phone = string.Empty;
|
||||
PhoneType = string.Empty;
|
||||
//IsFullTime = true;
|
||||
//IsEnrolledIn401k = true;
|
||||
//IsEnrolledInFlexTime = true;
|
||||
//IsEnrolledInHealthCare = true;
|
||||
//IsEnrolledInHSA = false;
|
||||
//IsActive = true;
|
||||
//BirthDate = "10-03-1975";
|
||||
StartTime = new TimeSpan(6, 0, 0);
|
||||
LoginId = string.Empty;
|
||||
FirstName = string.Empty;
|
||||
LastName = string.Empty;
|
||||
Email = string.Empty;
|
||||
Password = string.Empty;
|
||||
Phone = string.Empty;
|
||||
PhoneType = string.Empty;
|
||||
//IsFullTime = true;
|
||||
//IsEnrolledIn401k = true;
|
||||
//IsEnrolledInFlexTime = true;
|
||||
//IsEnrolledInHealthCare = true;
|
||||
//IsEnrolledInHSA = false;
|
||||
//IsActive = true;
|
||||
//BirthDate = "10-03-1975";
|
||||
StartTime = new TimeSpan(6, 0, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int UserId { get; set; }
|
||||
public string LoginId { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string PhoneType { get; set; }
|
||||
public bool IsFullTime { get; set; }
|
||||
public bool IsEnrolledIn401k { get; set; }
|
||||
public bool IsEnrolledInFlexTime { get; set; }
|
||||
public bool IsEnrolledInHealthCare { get; set; }
|
||||
public bool IsEnrolledInHSA { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
public TimeSpan StartTime { get; set; }
|
||||
|
||||
}
|
||||
// https://github.com/PaulDSheriff/PDSC-DevUtils
|
||||
|
||||
public int _UserId;
|
||||
public string _LoginId;
|
||||
public string _FirstName;
|
||||
public string _LastName;
|
||||
public string _Email;
|
||||
public string _Password;
|
||||
public string _Phone;
|
||||
public string _PhoneType;
|
||||
public bool _IsFullTime;
|
||||
public bool _IsEnrolledIn401k;
|
||||
public bool _IsEnrolledInFlexTime;
|
||||
public bool _IsEnrolledInHealthCare;
|
||||
public bool _IsEnrolledInHSA;
|
||||
public bool _IsActive;
|
||||
public DateTime _BirthDate;
|
||||
public TimeSpan _StartTime;
|
||||
|
||||
public int UserId
|
||||
{
|
||||
get { return _UserId; }
|
||||
set
|
||||
{
|
||||
_UserId = value;
|
||||
RaisePropertyChanged(nameof(UserId));
|
||||
}
|
||||
}
|
||||
|
||||
public string LoginId
|
||||
{
|
||||
get { return _LoginId; }
|
||||
set
|
||||
{
|
||||
_LoginId = value;
|
||||
RaisePropertyChanged(nameof(LoginId));
|
||||
}
|
||||
}
|
||||
|
||||
public string FirstName
|
||||
{
|
||||
get { return _FirstName; }
|
||||
set
|
||||
{
|
||||
_FirstName = value;
|
||||
RaisePropertyChanged(nameof(FirstName));
|
||||
}
|
||||
}
|
||||
|
||||
public string LastName
|
||||
{
|
||||
get { return _LastName; }
|
||||
set
|
||||
{
|
||||
_LastName = value;
|
||||
RaisePropertyChanged(nameof(LastName));
|
||||
}
|
||||
}
|
||||
|
||||
public string Email
|
||||
{
|
||||
get { return _Email; }
|
||||
set
|
||||
{
|
||||
_Email = value;
|
||||
RaisePropertyChanged(nameof(Email));
|
||||
}
|
||||
}
|
||||
public string Password
|
||||
{
|
||||
get { return _Password; }
|
||||
set
|
||||
{
|
||||
_Password = value;
|
||||
RaisePropertyChanged(nameof(Password));
|
||||
}
|
||||
}
|
||||
public string Phone
|
||||
{
|
||||
get { return _Phone; }
|
||||
set
|
||||
{
|
||||
_Phone = value;
|
||||
RaisePropertyChanged(nameof(Phone));
|
||||
}
|
||||
}
|
||||
public string PhoneType
|
||||
{
|
||||
get { return _PhoneType; }
|
||||
set
|
||||
{
|
||||
_PhoneType = value;
|
||||
RaisePropertyChanged(nameof(PhoneType));
|
||||
}
|
||||
}
|
||||
public bool IsFullTime
|
||||
{
|
||||
get { return _IsFullTime; }
|
||||
set
|
||||
{
|
||||
_IsFullTime = value;
|
||||
RaisePropertyChanged(nameof(IsFullTime));
|
||||
}
|
||||
}
|
||||
public bool IsEnrolledIn401k
|
||||
{
|
||||
get { return _IsEnrolledIn401k; }
|
||||
set
|
||||
{
|
||||
_IsEnrolledIn401k = value;
|
||||
RaisePropertyChanged(nameof(IsEnrolledIn401k));
|
||||
}
|
||||
}
|
||||
public bool IsEnrolledInFlexTime
|
||||
{
|
||||
get { return _IsEnrolledInFlexTime; }
|
||||
set
|
||||
{
|
||||
_IsEnrolledInFlexTime = value;
|
||||
RaisePropertyChanged(nameof(IsEnrolledInFlexTime));
|
||||
}
|
||||
}
|
||||
public bool IsEnrolledInHealthCare
|
||||
{
|
||||
get { return _IsEnrolledInHealthCare; }
|
||||
set
|
||||
{
|
||||
_IsEnrolledInHealthCare = value;
|
||||
RaisePropertyChanged(nameof(IsEnrolledInHealthCare));
|
||||
}
|
||||
}
|
||||
public bool IsEnrolledInHSA
|
||||
{
|
||||
get { return _IsEnrolledInHSA; }
|
||||
set
|
||||
{
|
||||
_IsEnrolledInHSA = value;
|
||||
RaisePropertyChanged(nameof(IsEnrolledInHSA));
|
||||
}
|
||||
}
|
||||
public bool IsActive
|
||||
{
|
||||
get { return _IsActive; }
|
||||
set
|
||||
{
|
||||
_IsActive = value;
|
||||
RaisePropertyChanged(nameof(IsActive));
|
||||
}
|
||||
}
|
||||
public DateTime BirthDate
|
||||
{
|
||||
get { return _BirthDate; }
|
||||
set
|
||||
{
|
||||
_BirthDate = value;
|
||||
RaisePropertyChanged(nameof(BirthDate));
|
||||
}
|
||||
}
|
||||
public TimeSpan StartTime
|
||||
{
|
||||
get { return _StartTime; }
|
||||
set
|
||||
{
|
||||
_StartTime = value;
|
||||
RaisePropertyChanged(nameof(StartTime));
|
||||
}
|
||||
}
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get { return $"{FirstName} {LastName}"; }
|
||||
}
|
||||
|
||||
public string LastNameFirstName
|
||||
{
|
||||
get { return $"{LastName}, {FirstName}"; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.MAUI", "Adve
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.EntityLayer", "AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj", "{33E62110-0EA1-48B1-B62F-CA856D13B114}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Library", "Common.Library\Common.Library.csproj", "{FEDB6441-2564-4DD5-A3C9-1B2F0A761BB4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -22,6 +24,10 @@ Global
|
||||
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FEDB6441-2564-4DD5-A3C9-1B2F0A761BB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FEDB6441-2564-4DD5-A3C9-1B2F0A761BB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FEDB6441-2564-4DD5-A3C9-1B2F0A761BB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FEDB6441-2564-4DD5-A3C9-1B2F0A761BB4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -66,6 +66,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -8,10 +8,20 @@ public partial class UserDetailView : ContentPage
|
||||
{
|
||||
InitializeComponent();
|
||||
UserObject = (User)this.Resources["viewModel"];
|
||||
UserObject.LoginId = "jkzxck0q94375";
|
||||
}
|
||||
|
||||
public User UserObject { get; set; }
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
UserObject.LoginId = "PeterPiper384";
|
||||
UserObject.FirstName = "Peter";
|
||||
UserObject.LastName = "Piper";
|
||||
UserObject.Email = "peter@piper.com";
|
||||
}
|
||||
private void SaveButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
System.Diagnostics.Debugger.Break();
|
||||
|
||||
30
Common.Library/BaseClasses/CommonBase.cs
Normal file
30
Common.Library/BaseClasses/CommonBase.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Common.Library;
|
||||
|
||||
public abstract class CommonBase : INotifyPropertyChanged
|
||||
{
|
||||
#region Constructor
|
||||
protected CommonBase()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Init Method
|
||||
public virtual void Init()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region RaisePropertyChanged Method
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
public virtual void RaisePropertyChanged(string propertyName)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
7
Common.Library/BaseClasses/EntityBase.cs
Normal file
7
Common.Library/BaseClasses/EntityBase.cs
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
namespace Common.Library
|
||||
{
|
||||
public class EntityBase : CommonBase
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Common.Library/Common.Library.csproj
Normal file
9
Common.Library/Common.Library.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user