DurnyklyYol/DurnyklyYol.Module/BusinessObjects/Client.cs

122 lines
3.8 KiB
C#
Raw Permalink Normal View History

2024-09-02 10:07:25 +00:00
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace DurnyklyYol.Module.BusinessObjects
{
[DefaultClassOptions, NavigationItem("Clients & Goods")]
[ImageName("BO_Customer")]
[DefaultProperty(nameof(FullName))]
//[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
//[Persistent("DatabaseTableName")]
// Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
public class Client : ApplicationUser
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
// Use CodeRush to create XPO classes and properties with a few keystrokes.
// https://docs.devexpress.com/CodeRushForRoslyn/118557
public Client(Session session)
: base(session)
{
}
protected override void OnSaving()
{
base.OnSaving();
if (Session.IsNewObject(this))
{
AssignClientRole();
}
}
private void AssignClientRole()
{
// Find the "Client" role in the database
var clientRole = Session.FindObject<PermissionPolicyRole>(
CriteriaOperator.Parse("Name == ?", GlobalConstants.ClientRoleName));
// If the role is found, assign it to the user
if (clientRole != null)
{
this.Roles.Add(clientRole);
}
}
2024-09-26 06:06:05 +00:00
string firebaseToken;
2024-09-02 10:07:25 +00:00
string bellik;
string telefon;
Region region;
string fullName;
//string phoneNo;
//[Size(8), ]
//public string PhoneNo
//{
// get => phoneNo;
// set => SetPropertyValue(nameof(PhoneNo), ref phoneNo, value);
//}
[Index(2)]
[Size(SizeAttribute.DefaultStringMappingFieldSize)]
public string Bellik
{
get => bellik;
set => SetPropertyValue(nameof(Bellik), ref bellik, value);
}
[Index(1)]
[Size(SizeAttribute.DefaultStringMappingFieldSize)]
public string Telefon
{
get => telefon;
set => SetPropertyValue(nameof(Telefon), ref telefon, value);
}
[Index(0)]
[Size(SizeAttribute.DefaultStringMappingFieldSize), RuleRequiredField(DefaultContexts.Save)]
public string FullName
{
get => fullName;
set => SetPropertyValue(nameof(FullName), ref fullName, value);
}
2024-09-26 06:06:05 +00:00
[Size(SizeAttribute.Unlimited)]
public string FirebaseToken
{
get => firebaseToken;
set => SetPropertyValue(nameof(FirebaseToken), ref firebaseToken, value);
}
2024-09-02 10:07:25 +00:00
[IgnoreDataMember]
public Region Region
{
get => region;
set => SetPropertyValue(nameof(Region), ref region, value);
}
[Association("Client-Goods"), Aggregated, IgnoreDataMember]
public XPCollection<Goods> Goods
{
get
{
return GetCollection<Goods>(nameof(Goods));
}
}
2024-09-26 06:06:05 +00:00
[Association("Client-CargoRequests")]
public XPCollection<CargoRequest> CargoRequests
{
get
{
return GetCollection<CargoRequest>(nameof(CargoRequests));
}
}
2024-09-02 10:07:25 +00:00
}
}