Files
narsil/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs
tanshu 49faa9786d Moved to a new printer name format in PrintLocation
If printing from windows, then the printer name should be prefixed with smb.
If printing from linux, then the printer name should be prefixed with cups.
If printing directly, then the printer name should be prefixed with pdl.
2018-05-17 15:52:27 +05:30

67 lines
2.9 KiB
C#

using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
using System;
using System.Collections.Generic;
namespace Tanshu.Accounts.Entities
{
public class Product
{
public virtual Guid ProductID { get; set; }
public virtual string Name { get; set; }
public virtual string Units { get; set; }
public virtual ProductGroup ProductGroup { get; set; }
public virtual Tax Vat { get; set; }
public virtual Tax ServiceTax { get; set; }
public virtual decimal ServiceCharge { get; set; }
public virtual bool IsScTaxable { get; set; }
public virtual decimal Price { get; set; }
public virtual bool HasHappyHour { get; set; }
public virtual bool IsActive { get; set; }
public virtual bool IsNotAvailable { get; set; }
public virtual int SortOrder { get; set; }
public virtual decimal Quantity { get; set; }
public virtual IList<Inventory> Inventories { get; set; }
public virtual string FullName
{
get
{
return Units == string.Empty ? Name : string.Format("{0} ({1})", Name, Units);
}
set { }
}
}
public class ProductMap : ClassMapping<Product>
{
public ProductMap()
{
Table("Products");
Schema("dbo");
Lazy(true);
Id(x => x.ProductID, map => map.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.UniqueKey("UQ_NameUnits"); });
Property(x => x.Units, map => { map.NotNullable(true); map.UniqueKey("UQ_NameUnits"); });
Property(x => x.ServiceCharge, map => map.NotNullable(true));
Property(x => x.IsScTaxable, map => map.NotNullable(true));
Property(x => x.Price, map => map.NotNullable(true));
Property(x => x.HasHappyHour, map => map.NotNullable(true));
Property(x => x.IsActive, map => map.NotNullable(true));
Property(x => x.IsNotAvailable, map => map.NotNullable(true));
Property(x => x.SortOrder, map => map.NotNullable(true));
Property(x => x.Quantity, map => map.NotNullable(true));
Property(x => x.FullName, map =>
{
map.Formula("CASE WHEN Units = '' THEN Name ELSE Name + ' (' + Units + ')' END");
});
ManyToOne(x => x.ProductGroup, map => { map.Column("ProductGroupID"); map.Cascade(Cascade.None); });
ManyToOne(x => x.ServiceTax, map => { map.Column("ServiceTaxID"); map.Cascade(Cascade.None); });
ManyToOne(x => x.Vat, map => { map.Column("VatID"); map.Cascade(Cascade.None); });
Bag(x => x.Inventories, colmap => { colmap.Key(x => x.Column("ProductID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}