Ejemplo n.º 1
0
        public PartialViewResult SaveGroupProduct(int?groupid, int?productid, int?xaction, int?groupcode)
        {
            if (xaction == 0) // xóa
            {
                var gr = db.ProductGroups.Find(groupid);

                db.ProductGroups.Remove(gr);

                db.SaveChanges();
            }
            else // thêm
            {
                var gr = new ProductGroup();
                gr.GroupCode = groupcode;
                gr.ProductID = productid;
                gr.Sort      = 1;

                db.ProductGroups.Add(gr);

                db.SaveChanges();
            }


            GroupCheck model = new GroupCheck();

            model = GroupCheck(productid);

            return(PartialView("_group", model));
        }
Ejemplo n.º 2
0
        public PartialViewResult GetGroupProduct(int?productid)
        {
            GroupCheck model = new GroupCheck();

            model = GroupCheck(productid);

            return(PartialView("_group", model));
        }
Ejemplo n.º 3
0
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Asc, SelfCheck.BasedOnStart, new double[] { "[0,start]:4000", "[0,end]:4000", "[1,start]:4000", "[1,end]:4000" })]
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Asc, SelfCheck.BasedOnEnd, new double[] { "[0,start]:3000", "[0,end]:3000", "[1,start]:3000", "[1,end]:3000" })]
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Desc, SelfCheck.BasedOnStart, new double[] { "[0,start]:2000", "[0,end]:2000", "[1,start]:2000", "[1,end]:2000" })]
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Desc, SelfCheck.BasedOnEnd, new double[] { "[0,start]:1000", "[0,end]:1000", "[1,start]:1000", "[1,end]:1000" })]
        public void TestFixInvalid(string[] timeTagTexts, GroupCheck other, SelfCheck self, string[] actualTimeTagTexts)
        {
            // check which part is fixed, using list of time to check result.
            var timeTags     = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var fixedTimeTag = TimeTagsUtils.FixInvalid(timeTags, other, self);

            TimeTagAssert.AreEqual(fixedTimeTag, TestCaseTagHelper.ParseTimeTags(actualTimeTagTexts));
        }
Ejemplo n.º 4
0
        //Get group products
        public PartialViewResult GetGroupProduct(int?productid)
        {
            GroupCheck model = new GroupCheck();

            model = GroupCheck(productid);

            return(PartialView("~/Areas/Quantri/Views/Products/_group.cshtml", model));
        }
Ejemplo n.º 5
0
        public void TestFindInvalid(string[] timeTagTexts, GroupCheck other, SelfCheck self, int[] errorIndex)
        {
            // run all and find invalid indexes.
            var timeTags       = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var invalidTimeTag = TimeTagsUtils.FindInvalid(timeTags, other, self);
            var invalidIndexes = invalidTimeTag.Select(v => timeTags.IndexOf(v)).ToArray();

            Assert.AreEqual(invalidIndexes, errorIndex);
        }
Ejemplo n.º 6
0
        public void TestFindOverlapping(string[] timeTagTexts, GroupCheck other, SelfCheck self, int[] errorIndex)
        {
            // run all and find overlapping indexes.
            var timeTags                  = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var overlappingTimeTags       = TimeTagsUtils.FindOverlapping(timeTags, other, self);
            var overlappingTimeTagIndexed = overlappingTimeTags.Select(v => timeTags.IndexOf(v)).ToArray();

            Assert.AreEqual(overlappingTimeTagIndexed, errorIndex);
        }
Ejemplo n.º 7
0
        public GroupCheck GroupCheck(int?productid)
        {
            GroupCheck model = new GroupCheck();

            var x = db.ProductGroups.Where(q => q.ProductID == productid).ToList();

            List <GroupProduct> allows    = new List <GroupProduct>();
            List <GroupProduct> available = new List <GroupProduct>();

            var y = x.FirstOrDefault(q => q.GroupCode == WebConstants.ProductMoi); // mới nhất

            GroupProduct g1 = new GroupProduct();

            g1.Title   = "Sản Phẩm Mới Nhất";
            g1.GroupID = 0;
            g1.IsGroup = 1;

            if (y != null)
            {
                g1.GroupID = y.ProductGroupID;

                allows.Add(g1);
            }
            else
            {
                available.Add(g1);
            }

            var y2 = x.FirstOrDefault(q => q.GroupCode == WebConstants.ProductDangKM); /// khuyến mãi

            GroupProduct g2 = new GroupProduct();

            g2.Title   = "Sản Phẩm Đang Khuyến Mãi";
            g2.GroupID = 0;
            g2.IsGroup = 2;

            if (y2 != null)
            {
                g2.GroupID = y2.ProductGroupID;

                allows.Add(g2);
            }
            else
            {
                available.Add(g2);
            }

            var y3 = x.FirstOrDefault(q => q.GroupCode == WebConstants.ProductNoiBat); //nổi bật

            GroupProduct g3 = new GroupProduct();

            g3.Title   = "Sản Phẩm Nổi Bật";
            g3.GroupID = 0;
            g3.IsGroup = 3;

            if (y3 != null)
            {
                g3.GroupID = y3.ProductGroupID;

                allows.Add(g3);
            }
            else
            {
                available.Add(g3);
            }

            var y4 = x.FirstOrDefault(q => q.GroupCode == WebConstants.ProductBanChay); /// bán chạy

            GroupProduct g4 = new GroupProduct();

            g4.Title   = "Sản Phẩm Bán Chạy";
            g4.GroupID = 0;
            g4.IsGroup = 4;
            if (y4 != null)
            {
                g4.GroupID = y4.ProductGroupID;

                allows.Add(g4);
            }
            else
            {
                available.Add(g4);
            }

            model.allows    = allows;
            model.available = available;


            return(model);
        }