public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class ClientInfoViewModel : LayoutViewModel
    {
        public string PayerName { get; set; }
        public Guid PayerId { get; set; }

        public PhonesListViewModel PhonesList { get; set; }
        public ClientRequisitesViewModel ClientRequisites { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class ClientInfoViewModel : LayoutViewModel
    {
        public string PayerName { get; set; }
        public Guid PayerId { get; set; }

        public PhonesListViewModel PhonesList { get; set; }
        public ClientRequisitesViewModel ClientRequisites { get; set; }
    }
public class PayerModel
    {
        public Guid Id { get; set; }
        public ClientType ClientType { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class ClientInfoViewModel : LayoutViewModel
    {
        public string PayerName { get; set; }
        public Guid PayerId { get; set; }

        public PhonesListViewModel PhonesList { get; set; }
        public ClientRequisitesViewModel ClientRequisites { get; set; }
    }
public class PayerModel
    {
        public Guid Id { get; set; }
        public ClientType ClientType { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class PayerViewModel
    {
        public Guid Id { get; set; }
        public PayerType Type { get; set; }
        public string RegionCode { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }

        public string LegalAddress { get; set; }
        public string BIK { get; set; }
        public string SettlementAccount { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class ClientInfoViewModel : LayoutViewModel
    {
        public string PayerName { get; set; }
        public Guid PayerId { get; set; }

        public PhonesListViewModel PhonesList { get; set; }
        public ClientRequisitesViewModel ClientRequisites { get; set; }
    }
public class PayerModel
    {
        public Guid Id { get; set; }
        public ClientType ClientType { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class PayerViewModel
    {
        public Guid Id { get; set; }
        public PayerType Type { get; set; }
        public string RegionCode { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }

        public string LegalAddress { get; set; }
        public string BIK { get; set; }
        public string SettlementAccount { get; set; }
    }
public class PayerViewModel
    {
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Name { get; set; }

        public string Bik { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class ClientInfoViewModel : LayoutViewModel
    {
        public string PayerName { get; set; }
        public Guid PayerId { get; set; }

        public PhonesListViewModel PhonesList { get; set; }
        public ClientRequisitesViewModel ClientRequisites { get; set; }
    }
public class PayerModel
    {
        public Guid Id { get; set; }
        public ClientType ClientType { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class PayerViewModel
    {
        public Guid Id { get; set; }
        public PayerType Type { get; set; }
        public string RegionCode { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }

        public string LegalAddress { get; set; }
        public string BIK { get; set; }
        public string SettlementAccount { get; set; }
    }
public class PayerViewModel
    {
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Name { get; set; }

        public string Bik { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
    }
public class PayerInfoViewModel
    {
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class AbonentViewModel
    {
        public AbonentViewModel()
        {
            AccessToPayer = AccessToPayer.Success;
        }

        public Guid AbonentId { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Address { get; set; }
        public string RegionCode { get; set; }

        public string AgentName { get; set; }
        public string PartnerName { get; set; }
        public string ServiceCenterCode { get; set; }

        public AccessToPayer AccessToPayer { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ProductId { get; set; }
        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Bik { get; set; }
        public string Phone { get; set; }
        public ClientType ClientType { get; set; }
        public bool IsDeleted { get; set; }

        public Dictionary<string, string> Products { get; set; }
    }
public class Abonent
    {
        private AbonentPhone[] phones;

        public Abonent()
        {
            phones = new AbonentPhone[0];
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string INN { get; set; }

        public virtual string KPP { get; set; }

        public virtual string RegionCode { get; set; }

        public virtual string City { get; set; }

        public virtual string SettlementAccount { get; set; }

        public virtual string BIK { get; set; }

        public virtual string ServiceCenterCode { get; set; }

        public virtual AbonentPhone[] Phones
        {
            get
            {
                return phones;
            }
            set
            {
                phones = value;
            }
        }

        public virtual string Comment { get; set; }

        public virtual DateTime CreatedDate { get; set; }

        public virtual bool IsBudget { get; set; }

        public virtual bool IsCorporate { get; set; }

        public virtual EdoSign IsEdo { get; set; }

        public virtual Guid TypeId { get; set; }

        public virtual Guid? AccountantId { get; set; }

        public virtual Guid? DirectorId { get; set; }

        public virtual string Fax { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual AbonentType Type { get; set; }

        public virtual string Address { get; set; }

        public virtual string AddressFact { get; set; }

        public virtual ClientType ClientType { get; set; }

        public virtual string Email { get; set; }

        public bool IsPotential { get; set; }

        public long Timestamp { get; set; }
    }
public class ClientViewModel : LayoutViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }

        public Guid? BillId { get; set; }
        public Guid? DocumentId { get; set; }

        public Dictionary<ClientBlockGroup, BaseClientBlock[]> Blocks { get; set; }
    }
public class ClientInfoViewModel
    {
        public Guid ClientId { get; set; }
        public string ClientName { get; set; }
        public string ProductId { get; set; }
    }
public class ClientInfoViewModel : LayoutViewModel
    {
        public string PayerName { get; set; }
        public Guid PayerId { get; set; }

        public PhonesListViewModel PhonesList { get; set; }
        public ClientRequisitesViewModel ClientRequisites { get; set; }
    }
public class PayerModel
    {
        public Guid Id { get; set; }
        public ClientType ClientType { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class PayerViewModel
    {
        public Guid Id { get; set; }
        public PayerType Type { get; set; }
        public string RegionCode { get; set; }
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }

        public string LegalAddress { get; set; }
        public string BIK { get; set; }
        public string SettlementAccount { get; set; }
    }
public class PayerViewModel
    {
        public string Inn { get; set; }
        public string Kpp { get; set; }
        public string Name { get; set; }

        public string Bik { get; set; }
        public string SettlementAccount { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
    }
public class PayerInfoViewModel
    {
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }
public class PayerQueryModel : QueryModel
    {
        public string Name { get; set; }
        public string Inn { get; set; }
        public string Kpp { get; set; }
    }

Когда выбирают GraphQL

  • используется микросервисная архитектура и REST стал слишком сложным
  • нужна экономия на объеме запросов
  • есть желание отвязать фронт от бека для ускорения и повышения качества разработки
  • хочется получить всегда актуальную документацию на халяву
public class GraphQlController: BaseApiController
    {
        private readonly ICSPayerServiceClient csPayerServiceClient;
        private readonly ICSPersonServiceClient csPersonServiceClient;
        private readonly IBillingGateway billingGateway;
        public GraphQlController(
            ICSPayerServiceClient csPayerServiceClient,
            ICSPersonServiceClient csPersonServiceClient,
            IBillingGateway billingGateway)
        {
            this.csPayerServiceClient = csPayerServiceClient;
            this.csPersonServiceClient = csPersonServiceClient;
            this.billingGateway = billingGateway;
        }
        public async Task<Abonent> GetClient(Guid id)
        {
            return await csPayerServiceClient.ReadAsync(id, false).ConfigureAwait(false);
        }
        public async Task<Person[]> GetPersons(Guid id)
        {
            return await csPersonServiceClient.SelectAsync(id).ConfigureAwait(false);
        }
        public BillModel[] GetBills(Guid id, string productId)
        {
            return billingGateway.SelectBillModels(id, productId, 1, 100);
        }
    }
app.get("/client/:clientId", (req, resp) => {
    const uri = "http://localhost:9501/api/GraphQl/GetClient/" + req.params.clientId;
    request(uri, (err, r , body) => {
        resp.send(body);
    })
});
app.get("/client/:clientId/persons", (req, res) => {
    const uri = "http://localhost:9501/api/GraphQl/GetPersons/" + req.params.clientId;
    request(uri, (err, r, body) => {
        res.send(body);
    });
});
app.get("/client/:clientId/bills/:productId", (req, res) => {
    const uri = "http://localhost:9501/api/GraphQl/GetBills/" + req.params.clientId + "?productId=" + req.params.productId;
    request(uri, (err, r, body) => {
        res.send(body);
    });
});
const ClientType = new GraphQLObjectType({
    name: "Client",
    fields: () => ({
        Id: { type: GraphQLString },
        Name: { type: GraphQLString },
        Bills: {
            type: new GraphQLList(BillType),
            description: "Счета. Данные из BillingGatewayClient по ClientId",
            args: {
                productId: {
                    type: new GraphQLNonNull(GraphQLString),
                    description: "Id продукта"
                }
            },
            resolve: // ...
        },
        Contacts: {
            type: new GraphQLList(ContactType),
            description: "Контакты клиента. Данные берутся из CS",
            args: {
                first: {
                    type: GraphQLInt,
                    description: "PageSize для выборки контактов клиента"
                }
            },
            resolve: // ...
        }
    })
});
const QueryType = new GraphQLObjectType({
    name: "Query",
    fields: () => ({
        Clients: {
            description: "Клиенты партнерки. Реальные данные строятся из бускадора CS",
            args: {
                id: {
                    type: new GraphQLNonNull(GraphQLString),
                    description: "Guid клиента"
                },
            },
            type: new GraphQLList(ClientType),
            resolve: // ...
        }
    })
});

Query

Contacts

Bills

Итоги

  • Один раз описать сущности
  • Не париться за документацию
  • Один API для всех
  • Возможность оптимизации запросов к API
  • Меньше времени на задачи и коммуникации
  • Избавление от тысяч ViewModel

Занимательное

Made with Slides.com