public void TestInitCatalogCoupon()
        {
            //making sure the table is empty
            TestBuisness.clearAllTable();

            uAdmin         = new Users_SystemAdministrator();
            user2          = new User();
            user2.userName = "******";
            uAdmin.User    = user2;
            cat1           = new CatalogCoupon();
            cat1.catalogID = 123;
            cat1.Users_SystemAdministrator = uAdmin;
            ca_da           = new CatalogCouponDataAccess();
            cat1.CouponName = "free resert";
            user1           = new User();
            c1                     = new Category();
            b1                     = new Buisness();
            l1                     = new Location();
            l1.latitude            = 34.8999;
            l1.longitude           = 45.3666;
            ub1                    = new Users_BuisnessOwner();
            b1.BuisDescription     = "Sushi bar";
            b1.buisAddress         = "Aharom Meskin 13";
            b1.buisCity            = "Beer-Sheva";
            b1.buisName            = "JAPANIKA";
            user1.userName         = "******";
            c1.catName             = "food";
            ub1.User               = user1;
            b1.Users_BuisnessOwner = ub1;
            b1.Category            = c1;
            b1.Location            = l1;
            cat1.Category          = c1;
            cat1.Location          = l1;
            cat1.Buisness          = b1;
        }
 public void updateCatalogCouponAverageRank()
 {
     using (var db = new CS_DBEntities3())//adding user and category for test
     {
         ca_da.addCatalogCoupon(cat1);
         Assert.IsTrue(ca_da.existsCatalogCoupon(cat1));
         double newValue = 13;
         ca_da.updatAverageRank(cat1, newValue);
         CatalogCoupon afterUpdate = ca_da.findCatalogCoupon(cat1);
         Assert.AreEqual(newValue, afterUpdate.averageRank);
         TestBuisness.clearAllTable();
     }
     TestBuisness.clearAllTable();
 }
 public void updateCatalogCouponDescription()
 {
     using (var db = new CS_DBEntities3())//adding user and category for test
     {
         ca_da.addCatalogCoupon(cat1);
         Assert.IsTrue(ca_da.existsCatalogCoupon(cat1));
         string newDescription = "Shusi and gril";
         ca_da.updateDescription(cat1, newDescription);
         CatalogCoupon afterUpdate = ca_da.findCatalogCoupon(cat1);
         Assert.AreEqual(newDescription, afterUpdate.description);
         TestBuisness.clearAllTable();
     }
     TestBuisness.clearAllTable();
 }
 public void updateCatalogCouponPriceAfterDiscount()
 {
     using (var db = new CS_DBEntities3())//adding user and category for test
     {
         ca_da.addCatalogCoupon(cat1);
         Assert.IsTrue(ca_da.existsCatalogCoupon(cat1));
         double newValue = 5.54;
         ca_da.updatePriceAfterDiscount(cat1, newValue);
         CatalogCoupon afterUpdate = ca_da.findCatalogCoupon(cat1);
         Assert.AreEqual(newValue, afterUpdate.priceAfterDiscount);
         TestBuisness.clearAllTable();
     }
     TestBuisness.clearAllTable();
 }
        public async Task <ActionResult> Edit(CatalogCouponViewModel catalogCouponViewModel)
        {
            if (ModelState.IsValid)
            {
                CatalogCoupon catalogCoupon = await _catalogCouponService.Find(catalogCouponViewModel.Id);

                if (catalogCoupon == null)
                {
                    return(HttpNotFound());
                }
                Mapper.Map(catalogCouponViewModel, catalogCoupon);
                catalogCoupon.UpdatedDate = DateTime.Now;
                await _catalogCouponService.UpdateAsync(catalogCoupon, catalogCouponViewModel.Id, true);

                return(RedirectToAction("Index"));
            }
            var categories = await _categoryService.GetAll();

            var products = await _productService.GetAll();

            ViewBag.ApplyForCategory = new SelectList(categories, "Id", "Name", catalogCouponViewModel.ApplyForCategory);
            ViewBag.ApplyForProduct  = new SelectList(products, "Id", "Title", catalogCouponViewModel.ApplyForProduct);
            return(View(catalogCouponViewModel));
        }