Implementing of viewModel handling for UI

This commit is contained in:
2025-08-19 16:50:53 +02:00
parent 86daaa5133
commit 2f053dfc71
8 changed files with 139 additions and 33 deletions

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,81 @@
using AdventureWorks.EntityLayer;
using Common.Library;
using System.Collections.ObjectModel;
namespace AdventureWorks.ViewModelLayer;
public class UserViewModel : ViewModelBase
{
#region Private Variables
private User? _UserObject = new();
#endregion
#region public Properties
public User? UserObject
{
get { return _UserObject; }
set
{
_UserObject = value;
RaisePropertyChanged(nameof(UserObject));
}
}
#endregion
#region Get Method
public ObservableCollection<User> Get()
{
return new();
}
#endregion
#region Get(id) Method
public User? Get(int id)
{
try
{
UserObject = new User
{
UserId = id,
LoginId = "SallyJones615",
FirstName = "Sally",
LastName = "Jones",
Email = "sally@jones.com",
Password = "password123",
Phone = "555-1234",
PhoneType = "Mobile",
IsFullTime = true,
IsEnrolledIn401k = false,
IsEnrolledInFlexTime = false,
IsEnrolledInHealthCare = true,
IsEnrolledInHSA = false,
IsActive = true,
BirthDate = Convert.ToDateTime("1975-11-04"),
StartTime = new TimeSpan(8, 0, 0)
};
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error in Get method: {ex.Message}");
}
return UserObject;
}
#endregion
#region Save Method
public virtual bool Save()
{
System.Diagnostics.Debugger.Break();
return true;
}
#endregion
}