Example #1
0
        public ModelPSaleItem GetSaleBirthday(decimal birthday, int agencyid)
        {
            var       date    = DateTime.Today;
            var       dateN   = date.TotalSeconds();
            var       dateNow = DateTime.Now.TotalSeconds();
            var       dateNe  = date.AddDays(1).TotalSeconds();
            var       dateM   = new DateTime(date.Year, date.Month, 1);
            var       dateMs  = dateM.TotalSeconds();
            var       dateMe  = dateM.AddMonths(1).TotalSeconds();
            bool      checkd  = dateN >= birthday && dateNe < birthday;
            bool      checkm  = dateMs >= birthday && dateMe < birthday;
            const int type    = (int)TypeEnumSale.Birthday;
            var       modelS  = new ModelPSaleItem
            {
                Sale = from o in FDIDB.DN_Sale
                       where (!o.IsEnd.HasValue || !o.IsEnd.Value) && o.IsShow == true && (!o.IsDeleted.HasValue || !o.IsDeleted.Value) &&
                       (!o.PriceLimit.HasValue || o.PriceLimit == 0 || (o.PriceLimit - (o.TotalUse ?? 0) > 0)) &&
                       (!o.IsAgency.HasValue || !o.IsAgency.Value || o.AgencyId == agencyid) && o.DateStart <dateNow && o.DateEnd> dateNow &&
                       ((o.IsMonth == true && checkm) || (o.IsDay == true && checkd)) && o.Type == type
                       select new Sale
                {
                    Price       = o.Price,
                    PercentSale = o.Percent,
                }
            };

            return(modelS);
        }
Example #2
0
        public ModelPSaleItem GetSaleProduct(int id, int agencyid)
        {
            const int type   = (int)TypeEnumSale.Product;
            var       date   = DateTime.Now.TotalSeconds();
            var       modelS = new ModelPSaleItem
            {
                Sale = from o in FDIDB.DN_Sale
                       where (!o.IsEnd.HasValue || !o.IsEnd.Value) && o.IsShow == true && (!o.IsDeleted.HasValue || !o.IsDeleted.Value) &&
                       (!o.PriceLimit.HasValue || o.PriceLimit == 0 || (o.PriceLimit - (o.TotalUse ?? 0) > 0)) && o.Type == type &&
                       (!o.IsAgency.HasValue || !o.IsAgency.Value || o.AgencyId == agencyid) && o.DateStart <date && o.DateEnd> date &&
                       (o.IsAll == true || o.Shop_Product_Detail.Any(k => k.ID == id) || o.Categories.Any(k => k.Shop_Product_Detail.Any(p => p.ID == id)) || o.Categories.Any(k => k.Category1.Any(c => c.Shop_Product_Detail.Any(p => p.ID == id))))
                       select new Sale
                {
                    Price        = o.Price,
                    PercentSale  = o.Percent,
                    IsAll        = o.IsAll,
                    QuantityCode = o.QuantityCode
                }
            };

            return(modelS);
        }