Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="LatestPage"></param>
        /// <returns></returns>
        public MyDiscount GetDiscountCoupons(int LatestPage = 0)
        {
            MyDiscount myDiscount = new MyDiscount();

            myDiscount.PageSize    = 10;
            myDiscount.CurrentPage = LatestPage > 0 ? LatestPage : CurrentPage;
            myDiscount.SortBy      = SortBy;

            var data = (from dis in bringlyEntities.tblCoupons
                        where dis.IsDeleted == false
                        join branch in bringlyEntities.tblBranches on dis.FK_BranchGuid equals branch.BranchGuid
                        where branch.FK_CreatedByGuid == UserVariables.LoggedInUserGuid
                        select new Discount
            {
                BranchGuid = branch.BranchGuid,
                CouponDescription = dis.CouponDescription,
                BranchName = branch.BranchName,
                CouponId = dis.CouponId,
                CouponName = dis.CouponName,
                CreatedByGuid = dis.FK_CreatedByGuid ?? Guid.Empty,
                DateCreated = dis.DateCreated,
                DiscountLimitationType = dis.DiscountLimitation,
                DiscountPriceType = dis.CouponPriceType,
                DiscountValue = dis.DiscountValue,
                DiscountType = dis.DiscountType,
                EndDate = dis.EndDate,
                IsActive = dis.IsActive,
                IsDeleted = dis.IsDeleted,
                StartDate = dis.StartDate
            });

            myDiscount.Discounts = data.OrderByDescending(dis => dis.DateCreated).ToList();

            myDiscount.TotalRecords = myDiscount.Discounts.Count;
            int skip = 0;

            if (myDiscount.CurrentPage == 1)
            {
                skip = 0;
            }
            else
            {
                skip = ((myDiscount.CurrentPage * myDiscount.PageSize) - myDiscount.PageSize);
            }

            myDiscount.Discounts = myDiscount.Discounts.Skip(skip).Take(myDiscount.PageSize).ToList();

            return(myDiscount);
        }
 private void PopulateLstMyDiscount()
 {
     // For a total of 5 times (5 columns), Create a MyDiscount object
     // Set Discount Percent and Calculate MyDiscount cost extended, margin extended, and margin/revenues percentage
     // Add MyDiscount to LstMyDiscount
     for (int i = 0; i < 5; i++)
     {
         MyDiscount md = new MyDiscount
         {
             ListPrice       = this.ListPrice,
             Cost            = this.AccountingCost,
             Quantity        = this.Quantity,
             DiscountPercent = this.Discount,
             Warranty        = this.Warranty
         };
         md.FinishSettingMyDiscount(i);
         this.LstMyDiscount.Add(md);
     }
 }