예제 #1
0
        protected bool Equals(DepartmentStockTempValid entity)
        {
            if (entity == null) return false;
            if (!base.Equals(entity)) return false;

            return true;
        }
 public void Delete(DepartmentStockTempValid data)
 {
     DepartmentStockTempValidDao.Delete(data);
 }
 public DepartmentStockTempValid Add(DepartmentStockTempValid data)
 {
     DepartmentStockTempValidDao.Add(data);
     return data;
 }
 public void Update(DepartmentStockTempValid data)
 {
     DepartmentStockTempValidDao.Update(data);
 }
 public static DepartmentStockTempValidDTO CreateFrom(DepartmentStockTempValid tempValid)
 {
     return new DepartmentStockTempValidDTO
                {
                    CreateDate = tempValid.DepartmentStockTempValidPK.CreateDate,
                    DepartmentId = tempValid.DepartmentStockTempValidPK.DepartmentId,
                    ProductMaster = tempValid.ProductMaster,
                    ProductColor = tempValid.Product.ProductColor,
                    ProductSize = tempValid.Product.ProductSize,
                    DepartmentStockTempValids = new List<DepartmentStockTempValid>
                                                    {
                                                        tempValid
                                                    }
                };
 }
        public DepartmentStockTempValid CreateFromProductId(string productId,long departmentId )
        {
            return (DepartmentStockTempValid)DepartmentStockTempValidDao.Execute(delegate(ISession session)
            {
                DepartmentStockTempValid tempValid = null;
                var query = session.Query<Product>();
                /*query.Expand("ProductMaster");*/
                Product foundedProduct =(from product in query.Fetch(x=>x.ProductMaster)
                                where product.ProductId == productId
                                select product).FirstOrDefault();
                if(foundedProduct!=null) // if found in db
                {
                    tempValid = new DepartmentStockTempValid
                                    {
                                        DepartmentStockTempValidPK = new DepartmentStockTempValidPK
                                        {
                                            CreateDate = DateTime.Now,
                                            DepartmentId = departmentId,
                                            ProductId = foundedProduct.ProductId
                                        },
                                        CreateId = "admin",
                                        UpdateId = "admin",
                                        UpdateDate = DateTime.Now,
                                        ProductMaster = foundedProduct.ProductMaster,
                                        Product = foundedProduct,
                                        DamageQuantity = 0,
                                        DelFlg = 0,
                                        ErrorQuantity = 0,
                                        ExclusiveKey = 0,
                                        Quantity = 0,
                                        GoodQuantity = 0
                                    };
                }
                else
                {
                    // TODO: SHOULD CREATE A TEMP PRODUCT HERE
                }

                return tempValid;
            }
                 );
        }