Implemented propertychanged pattern to connect UI with entity
This commit is contained in:
@ -6,4 +6,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
namespace AdventureWorks.EntityLayer.EntityClasses
|
using Common.Library;
|
||||||
{
|
|
||||||
public class User
|
namespace AdventureWorks.EntityLayer.EntityClasses;
|
||||||
|
|
||||||
|
public class User : EntityBase
|
||||||
{
|
{
|
||||||
public User()
|
public User()
|
||||||
{
|
{
|
||||||
@ -22,23 +24,181 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// https://github.com/PaulDSheriff/PDSC-DevUtils
|
||||||
|
|
||||||
public int UserId { get; set; }
|
public int _UserId;
|
||||||
public string LoginId { get; set; }
|
public string _LoginId;
|
||||||
public string FirstName { get; set; }
|
public string _FirstName;
|
||||||
public string LastName { get; set; }
|
public string _LastName;
|
||||||
public string Email { get; set; }
|
public string _Email;
|
||||||
public string Password { get; set; }
|
public string _Password;
|
||||||
public string Phone { get; set; }
|
public string _Phone;
|
||||||
public string PhoneType { get; set; }
|
public string _PhoneType;
|
||||||
public bool IsFullTime { get; set; }
|
public bool _IsFullTime;
|
||||||
public bool IsEnrolledIn401k { get; set; }
|
public bool _IsEnrolledIn401k;
|
||||||
public bool IsEnrolledInFlexTime { get; set; }
|
public bool _IsEnrolledInFlexTime;
|
||||||
public bool IsEnrolledInHealthCare { get; set; }
|
public bool _IsEnrolledInHealthCare;
|
||||||
public bool IsEnrolledInHSA { get; set; }
|
public bool _IsEnrolledInHSA;
|
||||||
public bool IsActive { get; set; }
|
public bool _IsActive;
|
||||||
public DateTime BirthDate { get; set; }
|
public DateTime _BirthDate;
|
||||||
public TimeSpan StartTime { get; set; }
|
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
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.EntityLayer", "AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj", "{33E62110-0EA1-48B1-B62F-CA856D13B114}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.EntityLayer", "AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj", "{33E62110-0EA1-48B1-B62F-CA856D13B114}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Library", "Common.Library\Common.Library.csproj", "{FEDB6441-2564-4DD5-A3C9-1B2F0A761BB4}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -66,6 +66,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
||||||
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -8,10 +8,20 @@ public partial class UserDetailView : ContentPage
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
UserObject = (User)this.Resources["viewModel"];
|
UserObject = (User)this.Resources["viewModel"];
|
||||||
|
UserObject.LoginId = "jkzxck0q94375";
|
||||||
}
|
}
|
||||||
|
|
||||||
public User UserObject { get; set; }
|
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)
|
private void SaveButton_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debugger.Break();
|
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