2011-06-29 20:27:07 +00:00
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
using NHibernate.Mapping.ByCode.Conformist;
|
|
|
|
|
using NHibernate.Mapping.ByCode;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
namespace Tanshu.Accounts.Entities
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public class Product
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public virtual Guid ProductID { get; set; }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual string Name { get; set; }
|
|
|
|
|
public virtual string Units { get; set; }
|
|
|
|
|
public virtual ProductGroup ProductGroup { get; set; }
|
2012-04-08 12:28:15 +00:00
|
|
|
|
public virtual Tax Vat { get; set; }
|
|
|
|
|
public virtual Tax ServiceTax { get; set; }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual decimal ServiceCharge { get; set; }
|
2012-04-08 12:28:15 +00:00
|
|
|
|
public virtual bool IsScTaxable { get; set; }
|
2011-08-28 12:17:15 +00:00
|
|
|
|
public virtual decimal Price { get; set; }
|
|
|
|
|
public virtual decimal FullPrice { get; set; }
|
2014-10-16 11:11:55 +00:00
|
|
|
|
public virtual bool IsActive { get; set; }
|
|
|
|
|
public virtual bool IsNotAvailable { get; set; }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual int SortOrder { get; set; }
|
2011-12-05 09:41:02 +00:00
|
|
|
|
public virtual decimal Quantity { get; set; }
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public virtual IList<Inventory> Inventories { get; set; }
|
|
|
|
|
|
2016-03-29 07:22:33 +00:00
|
|
|
|
public virtual string FullName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Units == string.Empty ? Name : string.Format("{0} ({1})", Name, Units);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2014-10-12 09:41:45 +00:00
|
|
|
|
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.FullPrice, map => map.NotNullable(true));
|
2014-10-16 11:11:55 +00:00
|
|
|
|
Property(x => x.IsActive, map => map.NotNullable(true));
|
|
|
|
|
Property(x => x.IsNotAvailable, map => map.NotNullable(true));
|
2014-10-12 09:41:45 +00:00
|
|
|
|
Property(x => x.SortOrder, map => map.NotNullable(true));
|
|
|
|
|
Property(x => x.Quantity, map => map.NotNullable(true));
|
|
|
|
|
|
|
|
|
|
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(); });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|