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( CriteriaOperator.Parse("Name == ?", GlobalConstants.ClientRoleName)); // If the role is found, assign it to the user if (clientRole != null) { this.Roles.Add(clientRole); } } 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); } [IgnoreDataMember] public Region Region { get => region; set => SetPropertyValue(nameof(Region), ref region, value); } [Association("Client-Goods"), Aggregated, IgnoreDataMember] public XPCollection Goods { get { return GetCollection(nameof(Goods)); } } } }