/// <summary>
 /// Adds the discountPackage.
 /// </summary>
 /// <param name="discountPackage">The discountPackage.</param>
 public void AddDiscountPackage(DiscountPackage discountPackage)
 {
     using (var context = new MyApplicationContext())
     {
         context.DiscountPackages.Add(discountPackage);
         context.SaveChanges();
     }
 }
 public void SetUp()
 {
     // a valid discountPackage
     discountPackage = new DiscountPackage()
     {
         Discount = 25
     };
 }
        public void TestDiscountPackageUpdate()
        {
            DiscountPackage discountPackage = new DiscountPackage() { Id = 14 };

            discountPackageDataService.Expect(dao => dao.UpdateDiscountPackage(discountPackage));

            discountPackageService.UpdateDiscountPackage(discountPackage);

            discountPackageDataService.VerifyAllExpectations();
        }
        public void TestDiscountPackageAdd()
        {
            DiscountPackage discountPackage = new DiscountPackage() { Id = 15 };

            discountPackageDataService.Expect(dao => dao.AddDiscountPackage(discountPackage));

            discountPackageService.AddDiscountPackage(discountPackage);

            discountPackageDataService.VerifyAllExpectations();
        }
 /// <summary>
 /// Deletes the discountPackage.
 /// </summary>
 /// <param name="discountPackage">The discountPackage.</param>
 public void DeleteDiscountPackage(DiscountPackage discountPackage)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new DiscountPackage { Id = discountPackage.Id };
         context.DiscountPackages.Attach(newProd);
         context.DiscountPackages.Remove(newProd);
         context.SaveChanges();
     }
 }
        public void TestDiscountPackageGetById()
        {
            int id = 15;
            DiscountPackage discountPackage = new DiscountPackage() { Id = id };

            discountPackageDataService.Stub(dao => dao.GetDiscountPackageById(id)).Return(discountPackage);

            DiscountPackage result = discountPackageService.GetDiscountPackageById(id);

            Assert.AreEqual(id, result.Id);
        }
 /// <summary>
 /// Updates the discountPackage.
 /// </summary>
 /// <param name="discountPackage">The discountPackage.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateDiscountPackage(DiscountPackage discountPackage)
 {
     using (var context = new MyApplicationContext())
     {
         DiscountPackage discountPackageRef = context.DiscountPackages.Where(c => c.Id == discountPackage.Id).SingleOrDefault();
         if (discountPackageRef != null)
         {
             discountPackageRef = discountPackage;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }
        public void TestDiscountPackageGetListOfDiscountPackages()
        {
            DiscountPackage discountPackage1 = new DiscountPackage()
            {
                Id = 11
            };
            DiscountPackage discountPackage2 = new DiscountPackage()
            {
                Id = 12
            };
            IList<DiscountPackage> discountPackages = new List<DiscountPackage>() { discountPackage1, discountPackage2 };

            discountPackageDataService.Stub(dao => dao.GetAllDiscountPackages()).Return(discountPackages);

            var result = discountPackageService.GetListOfDiscountPackages();

            Assert.AreEqual(result.Count, discountPackages.Count);
        }
 public void UpdateDiscountPackage(DiscountPackage discountPackage)
 {
     discountPackageDataService.UpdateDiscountPackage(discountPackage);
 }
 public void DeleteDiscountPackage(DiscountPackage discountPackage)
 {
     discountPackageDataService.DeleteDiscountPackage(discountPackage);
 }
 public void AddDiscountPackage(DiscountPackage discountPackage)
 {
     discountPackageDataService.AddDiscountPackage(discountPackage);
 }