Beispiel #1
0
        static void Main(string[] args)
        {
            AnimalsList zooAnimals = AnimalsList.Animals();

            animalsList.ShowAnimals();

            Animal animalsactivity = new ConcreteAnimal();

            IAnimalsActivity horse = animalsactivity.GetAnimal("Horse");

            Horse.Drive(10);

            IAnimalsActivity dog = animalsactivity.GetAnimal("Dog");

            dog.Drive(5);
            Console.ReadKey();

            AnimalsList.Instance.Show();
            AnimalsList.Instance.Show();
            Console.ReadKey();

            SpecialOffer offer = new SpecialOffer(car);

            offer.DiscountPercentage = 25;
            offer.Offer = "25 % discount";

            Console.WriteLine("{1} @ Zoo Special Offer and price are : {0} ", offer.Price, offer.Offer);
            Console.ReadKey();
        }
        public ActionResult Create()
        {
            SpecialOffer specialOffer = new SpecialOffer();

            specialOffer.hotels = new List <HotelSpecialOffer>();
            return(View(specialOffer));
        }
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                SpecialOffer mock   = CreateMockInstance(tm);
                bool         result = DataRepository.SpecialOfferProvider.Insert(tm, mock);

                Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed");

                SpecialOfferQuery query = new SpecialOfferQuery();

                query.AppendEquals(SpecialOfferColumn.SpecialOfferId, mock.SpecialOfferId.ToString());
                query.AppendEquals(SpecialOfferColumn.Description, mock.Description.ToString());
                query.AppendEquals(SpecialOfferColumn.DiscountPct, mock.DiscountPct.ToString());
                query.AppendEquals(SpecialOfferColumn.Type, mock.Type.ToString());
                query.AppendEquals(SpecialOfferColumn.Category, mock.Category.ToString());
                query.AppendEquals(SpecialOfferColumn.StartDate, mock.StartDate.ToString());
                query.AppendEquals(SpecialOfferColumn.EndDate, mock.EndDate.ToString());
                query.AppendEquals(SpecialOfferColumn.MinQty, mock.MinQty.ToString());
                if (mock.MaxQty != null)
                {
                    query.AppendEquals(SpecialOfferColumn.MaxQty, mock.MaxQty.ToString());
                }
                query.AppendEquals(SpecialOfferColumn.Rowguid, mock.Rowguid.ToString());
                query.AppendEquals(SpecialOfferColumn.ModifiedDate, mock.ModifiedDate.ToString());

                TList <SpecialOffer> results = DataRepository.SpecialOfferProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
Beispiel #4
0
        public async Task <IActionResult> PutSpecialOffer(int id, SpecialOffer specialOffer)
        {
            if (id != specialOffer.SpecOfferId)
            {
                return(BadRequest());
            }

            _context.Entry(specialOffer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpecialOfferExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #5
0
        ///<summary>
        ///  Returns a Typed SpecialOfferProduct Entity with mock values.
        ///</summary>
        static public SpecialOfferProduct CreateMockInstance_Generated(TransactionManager tm)
        {
            SpecialOfferProduct mock = new SpecialOfferProduct();

            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

            //OneToOneRelationship
            Product mockProductByProductId = ProductTest.CreateMockInstance(tm);

            DataRepository.ProductProvider.Insert(tm, mockProductByProductId);
            mock.ProductId = mockProductByProductId.ProductId;
            //OneToOneRelationship
            SpecialOffer mockSpecialOfferBySpecialOfferId = SpecialOfferTest.CreateMockInstance(tm);

            DataRepository.SpecialOfferProvider.Insert(tm, mockSpecialOfferBySpecialOfferId);
            mock.SpecialOfferId = mockSpecialOfferBySpecialOfferId.SpecialOfferId;

            // create a temporary collection and add the item to it
            TList <SpecialOfferProduct> tempMockCollection = new TList <SpecialOfferProduct>();

            tempMockCollection.Add(mock);
            tempMockCollection.Remove(mock);


            return((SpecialOfferProduct)mock);
        }
        public bool UpdateSpecialOffer(SpecialOffer SO)
        {
            IDBManager dbm = new DBManager();

            try
            {
                dbm.CreateParameters(10);
                dbm.AddParameters(0, "@SpecialOfferID", SO.SpecialOfferID);
                dbm.AddParameters(1, "@Description", SO.Description);
                dbm.AddParameters(2, "@DiscountPct", SO.DiscountPct);
                dbm.AddParameters(3, "@Type", SO.Type);
                dbm.AddParameters(4, "@Category", SO.Category);
                dbm.AddParameters(5, "@StartDate", SO.StartDate);
                dbm.AddParameters(6, "@EndDate", SO.EndDate);
                dbm.AddParameters(7, "@MaxQty", SO.MaxQty);
                dbm.AddParameters(8, "@MinQty", SO.MinQty);
                dbm.AddParameters(9, "@ModifiedDate", DateTime.Now);
                dbm.ExecuteNonQuery(CommandType.StoredProcedure, "UpdateSpecialOffer");
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "UpdateSpecialOffer");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(true);
        }
Beispiel #7
0
        public async Task CreateAllAsync_ShouldReturnCorrectResult()
        {
            var errorMessage = "SpecialOffersService CreateAllAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new SpecialOffersServiceTestsSeeder();
            await seeder.SeedHotelAsync(context);

            var specialOfferRepository = new EfDeletableEntityRepository <SpecialOffer>(context);
            var specialOffersService   = this.GetSpecialOffersService(specialOfferRepository, context);

            // Act
            var specialOffer = new SpecialOffer
            {
                Title        = "Title1",
                Content      = "Content1",
                ShortContent = "ShortContenr1",
                HotelDataId  = context.Hotels.FirstOrDefault().Id,
            };

            await specialOffersService.CreateAllAsync(new List <SpecialOffer> {
                specialOffer
            });

            var actualResult   = specialOfferRepository.All().First();
            var expectedResult = specialOffer;

            // Assert
            Assert.True(expectedResult.Title == actualResult.Title, errorMessage + " " + "Title is not returned properly.");
            Assert.True(expectedResult.Content == actualResult.Content, errorMessage + " " + "Content is not returned properly.");
            Assert.True(expectedResult.ShortContent == actualResult.ShortContent, errorMessage + " " + "Short content is not returned properly.");
            Assert.True(expectedResult.HotelDataId == actualResult.HotelDataId, errorMessage + " " + "Hotel is not returned properly.");
        }
Beispiel #8
0
        public async Task <IActionResult> PutSpecialOffer(int id, SpecialOffer specialOffer)
        {
            var claimsIdentity = this.User.Identity as ClaimsIdentity;                // Calling User Data From Users Controller
            var Myusername     = claimsIdentity.FindFirst(ClaimTypes.Surname)?.Value; // Finding Current User

            if (id != specialOffer.SpecialOfferId)
            {
                return(BadRequest());
            }
            specialOffer.SpecialOfferId = id;
            specialOffer.ModifiedUserId = int.Parse(User.Identity.Name); // Auto Update
            specialOffer.ModifiedBy     = Myusername;                    // Auto Update
            specialOffer.ModifiedDate   = DateTime.Now;                  // Auto Update

            _context.Entry(specialOffer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpecialOfferExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        ///     Edit offer in system
        /// </summary>
        /// <param name="model">ProductViewModel</param>
        /// <param name="p">Product</param>
        public void Update(ProductViewModel model, Product p)
        {
            if (model.OfferPrice == 0)
            {
                Delete(p);
            }
            else
            {
                List <SpecialOffer> allOffers = offerRepo.RetrieveAllOffers();
                if (allOffers.Where(x => x.RetrieveProductId() == p.RetrieveProductId()).FirstOrDefault() != null)
                {
                    foreach (var singleOffer in allOffers)
                    {
                        if (singleOffer.RetrieveProductId() == p.RetrieveProductId())
                        {
                            var specialOffer = new SpecialOffer(singleOffer.RetrieveOfferId(), model.OfferPrice, p.RetrieveProductId(), p.ProductName);
                            specialOffer.StartTime = model.OfferStart;
                            specialOffer.EndTime   = model.OfferEnd;

                            offerRepo.UpdateOfferById(specialOffer);
                        }
                    }
                }
                else
                {
                    Add(model, p);
                }
            }
        }
Beispiel #10
0
        public async Task CreateAllAsync_ShouldShouldSuccessfullyCreate()
        {
            var errorMessagePrefix = "SpecialOffersService CreateAllAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new SpecialOffersServiceTestsSeeder();
            await seeder.SeedHotelAsync(context);

            var specialOfferRepository = new EfDeletableEntityRepository <SpecialOffer>(context);
            var specialOffersService   = this.GetSpecialOffersService(specialOfferRepository, context);

            // Act
            var specialOffer = new SpecialOffer
            {
                Title        = "Title1",
                Content      = "Content1",
                ShortContent = "ShortContenr1",
                HotelDataId  = context.Hotels.FirstOrDefault().Id,
            };
            var result = await specialOffersService.CreateAllAsync(new List <SpecialOffer> {
                specialOffer
            });

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }
        public SpecialOffer GetSpecialOffer(int SpecialOfferID)
        {
            IDBManager   dbm = new DBManager();
            SpecialOffer SO  = new SpecialOffer();

            try
            {
                dbm.CreateParameters(1);
                dbm.AddParameters(0, "@SpecialOfferID", SpecialOfferID);
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOffer");
                while (reader.Read())
                {
                    SO.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString());
                    SO.Description    = reader["Description"].ToString();
                    SO.Category       = reader["Category"].ToString();
                    SO.DiscountPct    = decimal.Parse(reader["DiscountPct"].ToString());
                    SO.EndDate        = DateTime.Parse(reader["EndDate"].ToString());
                    SO.MaxQty         = Int32.Parse(reader["MaxQty"].ToString());
                    SO.MinQty         = Int32.Parse(reader["MinQty"].ToString());
                    SO.StartDate      = DateTime.Parse(reader["StartDate"].ToString());
                    SO.Type           = reader["Type"].ToString();
                    SO.ModifiedDate   = DateTime.Parse(reader["ModifiedDate"].ToString());
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetSpecialOffer");
                throw (ex);;
            }
            finally
            {
                dbm.Dispose();
            }
            return(SO);
        }
        public int AddSpecialOffer(SpecialOffer SO)
        {
            IDBManager dbm = new DBManager();

            try
            {
                dbm.CreateParameters(10);
                dbm.AddParameters(0, "@Description", SO.Description);
                dbm.AddParameters(1, "@DiscountPct", SO.DiscountPct);
                dbm.AddParameters(2, "@Type", SO.Type);
                dbm.AddParameters(3, "@Category", SO.Category);
                dbm.AddParameters(4, "@StartDate", SO.StartDate);
                dbm.AddParameters(5, "@EndDate", SO.EndDate);
                dbm.AddParameters(6, "@MinQty", SO.MinQty);
                dbm.AddParameters(7, "@MaxQty", SO.MaxQty);
                dbm.AddParameters(8, "@ModifiedDate", DateTime.Now);
                dbm.AddParameters(9, "@SpecialOfferID", SO.SpecialOfferID);
                dbm.Parameters[9].Direction = ParameterDirection.Output;

                dbm.ExecuteNonQuery(CommandType.StoredProcedure, "InsertSpecialOffer");
                SO.SpecialOfferID = Int32.Parse(dbm.Parameters[9].Value.ToString());
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "InsertSpecialOffer");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(SO.SpecialOfferID);
        }
        public bool SpecialOfferUpdate(SpecialOffer specialoffer)
        {
            return(Execute <bool>(dal =>
            {
                SpecialOffer specialofferUpdate = dal.SpecialOffer.Where(x => x.SpecialOfferID == specialoffer.SpecialOfferID).FirstOrDefault();
                if (specialofferUpdate != null)
                {
                    specialofferUpdate.SpecialOfferID = specialoffer.SpecialOfferID;
                    specialofferUpdate.Description = specialoffer.Description;
                    specialofferUpdate.DiscountPct = specialoffer.DiscountPct;
                    specialofferUpdate.Type = specialoffer.Type;
                    specialofferUpdate.Category = specialoffer.Category;
                    specialofferUpdate.StartDate = specialoffer.StartDate;
                    specialofferUpdate.EndDate = specialoffer.EndDate;
                    specialofferUpdate.MinQty = specialoffer.MinQty;
                    specialofferUpdate.MaxQty = specialoffer.MaxQty;
                    specialofferUpdate.rowguid = specialoffer.rowguid;
                    specialofferUpdate.ModifiedDate = specialoffer.ModifiedDate;

                    dal.SubmitChanges();
                    return true;
                }
                return false;
            }));
        }
        private static void CalculateTotalWithSpecialOffer(BasketItem basketItem, SpecialOffer itemSpecialOffer, ref int basketItemQty, ref decimal total)
        {
            while (true)
            {
                if (basketItemQty == itemSpecialOffer.Quantity)
                {
                    total += itemSpecialOffer.Price;
                }
                else
                {
                    if (basketItemQty > itemSpecialOffer.Quantity)
                    {
                        basketItemQty -= itemSpecialOffer.Quantity;

                        total += itemSpecialOffer.Price;
                        continue;
                    }
                    else
                    {
                        total += basketItem.Price * basketItemQty;
                    }
                }

                break;
            }
        }
Beispiel #15
0
        public async Task AddSpecialOfferAsync_WithIncorrectProperty_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new SpecialOffersServiceTestsSeeder();
            await seeder.SeedSpecialOfferAsync(context);

            var specialOfferRepository = new EfDeletableEntityRepository <SpecialOffer>(context);
            var specialOffersService   = this.GetSpecialOffersService(specialOfferRepository, context);

            var specialOffer = new SpecialOffer
            {
                Title        = null,
                Content      = null,
                ShortContent = "ShortContenr1",
                HotelDataId  = context.Hotels.FirstOrDefault().Id,
            };

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await specialOffersService.AddSpecialOfferAsync(specialOffer);
            });
        }
        private void PopulateGrids()
        {
            //special offer
            SpecialOffer so = new SpecialOffer();

            try
            {
                DataSet ds = new DataSet();
                ds = so.GetAllSpecialOffersDataSet();
                dgSpecialOffers.DataSource = ds.Tables[0];
                dgSpecialOffers.Columns["specialofferid"].HeaderText = "ID";
                dgSpecialOffers.Columns["specialofferid"].Width      = 60;
                dgSpecialOffers.Columns["description"].Width         = 250;
                dgSpecialOffers.Columns["type"].Width           = 40;
                dgSpecialOffers.Columns["startdate"].Width      = 150;
                dgSpecialOffers.Columns["enddate"].Width        = 150;
                dgSpecialOffers.Columns["startdate"].HeaderText = "Start Date/Time";
                dgSpecialOffers.Columns["enddate"].HeaderText   = "End Date/Time";
                dgSpecialOffers.Columns["MinQty"].Width         = 70;
                dgSpecialOffers.Columns["MaxQty"].Width         = 70;
                dgSpecialOffers.Columns["modifieddate"].Visible = false;

                //dgSpecialOffers.Columns[
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                so = null;
            }
        }
        public void CanTotalMultipleSpecialOffersAndNonQualifyingItems()
        {
            var item1 = new ItemBuilder().WithSku("A99").WithPrice(0.50m).Build();
            var item2 = new ItemBuilder().WithSku("B15").WithPrice(0.30m).Build();
            var item3 = new ItemBuilder().WithSku("B15").WithPrice(0.30m).Build();
            var item4 = new ItemBuilder().WithSku("B15").WithPrice(0.30m).Build();
            var item5 = new ItemBuilder().WithSku("C40").WithPrice(0.60m).Build();
            var item6 = new ItemBuilder().WithSku("A99").WithPrice(0.50m).Build();
            var item7 = new ItemBuilder().WithSku("A99").WithPrice(0.50m).Build();

            var offer = new SpecialOffer {
                Sku = "B15", Price = 0.45m, Quantity = 2
            };
            var offer2 = new SpecialOffer {
                Sku = "A99", Price = 1.30m, Quantity = 3
            };

            // this does require the offer to be added before scanning.
            // However gives flexibility that you can add offers rather than them being set in the Checkout itself.
            _itemUnderTest.AddSpecialOffer(offer);
            _itemUnderTest.AddSpecialOffer(offer2);

            _itemUnderTest.Scan(item1);
            _itemUnderTest.Scan(item2);
            _itemUnderTest.Scan(item3);
            _itemUnderTest.Scan(item4);
            _itemUnderTest.Scan(item5);
            _itemUnderTest.Scan(item6);
            _itemUnderTest.Scan(item7);

            _itemUnderTest.Total().ShouldEqual(2.65m);
        }
Beispiel #18
0
        public override void DiscountSale(SpecialOffer specialOffer, Game game)
        {
            double discount;

            discount = game.Price - (specialOffer.DiscountPercent / 100 * game.Price);
            Console.WriteLine("{0} on {1} reduced the price to {2}TL with a {3}% discount rate.", specialOffer.NameOfOffer, game.NameOfGame, discount, specialOffer.DiscountPercent);
        }
Beispiel #19
0
        public async Task <ActionResult <SpecialOffer> > PostSpecialOffer(SpecialOffer specialOffer)
        {
            _context.specialOffers.Add(specialOffer);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSpecialOffer", new { id = specialOffer.SpecOfferId }, specialOffer));
        }
        public SpecialOffer RetrieveOfferByProductID(int productId)
        {
            var offer = new SpecialOffer(-1, 1, 1, null);

            try
            {
                SqlConnection cnn   = ReturnSQLConnection();
                string        query = "SELECT * FROM dbo.[SpecialOffer] where ProductID = @ProductID";
                SqlCommand    cmd   = CreateSQLCommandText(query, cnn);
                cmd.Parameters.AddWithValue("@ProductID", productId);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var id         = Convert.ToInt32(dr["Id"]);
                    var start      = Convert.ToDateTime(dr["Startdate"]);
                    var end        = Convert.ToDateTime(dr["Enddate"]);
                    var offerPrice = Convert.ToDecimal(dr["OfferPrice"]);

                    var productRep = new ProductRepository(new ProductMssqlContext());
                    var product    = productRep.RetrieveProductById(productId);

                    offer           = new SpecialOffer(id, offerPrice, product.RetrieveProductId(), product.ProductName);
                    offer.StartTime = start;
                    offer.EndTime   = end;
                }
                cnn.Close();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e.Message);
            }
            return(offer);
        }
Beispiel #21
0
        private void PopulateSpecialOfferGrid(int productID)
        {
            SpecialOfferProduct sop = new SpecialOfferProduct();
            SpecialOffer        so  = new SpecialOffer();

            try
            {
                SetupSpecialOfferGrid();
                string where = string.Format("startDate <= getdate() and endDate >= getdate() and exists(select 1 from SpecialOfferProduct where specialofferid=SpecialOffer.specialofferid and productID={0})", productID);
                string orderBy             = "enddate";
                SpecialOfferCollection soc = so.GetSpecialOffersCollection(where, orderBy);
                DataTable dt = new DataTable();
                foreach (SpecialOffer s in soc)
                {
                    DataRow dr = dsSpeicalOffer.Tables[0].NewRow();
                    dr[0] = s.Description;
                    dr[1] = s.DiscountPct;
                    dsSpeicalOffer.Tables[0].Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error. Failed to load Speical Offers for this product");
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            Customer customer = new Customer
            {
                CustomerID     = 1,
                FirstName      = "Tarık",
                LastName       = "Göl",
                IdentityNumber = "12345",
                DateOfBirth    = new DateTime(1997, 9, 8)
            };

            SpecialOffer specialOffer = new SpecialOffer()
            {
                SpecialOfferID       = 1,
                SpecialOfferType     = "25% Discount",
                isSpecialOfferActive = true
            };

            SpecialOfferManager specialOfferManager = new SpecialOfferManager();

            specialOfferManager.AddSpecialOffer(specialOffer);

            CustomerManager customerManager = new CustomerManager(new CustomerValidationManager());

            customerManager.SignUp(customer);

            GameStoreManager gameStoreManager = new GameStoreManager();

            gameStoreManager.BuyGames(specialOffer);

            specialOfferManager.RemoveSpecialOffer(specialOffer);

            gameStoreManager.BuyGames(specialOffer);
        }
Beispiel #23
0
        static void Main(string[] args)
        {
            Customer customer = new Customer
            {
                CustomerID     = 1,
                FirstName      = "Hasan",
                LastName       = "Bozkurt",
                IdentityNumber = "2728562645",
                DateOfBirth    = new DateTime(1996, 9, 5)
            };

            SpecialOffer specialOffer = new SpecialOffer()
            {
                SpecialOfferID     = 1,
                SpecialOfferType   = "25% İndirimle",
                SpecialOfferActive = true
            };

            SpecialOfferManager specialOfferManager = new SpecialOfferManager();

            specialOfferManager.AddSpecialOffer(specialOffer);

            CustomerManager customerManager = new CustomerManager(new CustomerValidationManager());

            customerManager.SignUp(customer);

            GameStoreManager gameStoreManager = new GameStoreManager();

            gameStoreManager.BuyGames(specialOffer);

            specialOfferManager.RemoveSpecialOffer(specialOffer);

            gameStoreManager.BuyGames(specialOffer);
        }
        /// <summary>
        /// Deep load all SpecialOffer children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.SpecialOfferProvider.GetPaged(tm, 0, 10, out count);

                DataRepository.SpecialOfferProvider.DeepLoading += new EntityProviderBaseCore <SpecialOffer, SpecialOfferKey> .DeepLoadingEventHandler(
                    delegate(object sender, DeepSessionEventArgs e)
                {
                    if (e.DeepSession.Count > 3)
                    {
                        e.Cancel = true;
                    }
                }
                    );

                if (mockCollection.Count > 0)
                {
                    DataRepository.SpecialOfferProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("SpecialOffer instance correctly deep loaded at 1 level.");

                    mockCollection.Add(mock);
                    // DataRepository.SpecialOfferProvider.DeepSave(tm, mockCollection);
                }

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        // GET: SpecialOffers/Delete/5
        public ActionResult Delete(int?id)
        {
            SpecialOffer specialOffer = db.SpecialOffers.Find(id);

            specialOffer.IsDeleted = true;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #26
0
        public void Add(SpecialOffer specialOffer)
        {
            var offerId = _database.Keys.Any() ? _database.Keys.Max() + 1 : 1;

            specialOffer.Id = offerId;
            _database.Add(offerId, specialOffer);
            _eventStore.Raise("NewSpecialOffer", specialOffer);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SpecialOffer specialOffer = db.SpecialOffers.Find(id);

            db.SpecialOffers.Remove(specialOffer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #28
0
        ///<summary>
        ///  Update the Typed SpecialOffer Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, SpecialOffer mock)
        {
            SpecialOfferTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
Beispiel #29
0
        public double CalculateDiscount(Game game, SpecialOffer offer)
        {
            double _gamePrice    = game.GamePrice;
            double _discountRate = offer.DiscountRate;

            double _discount = (_gamePrice - ((_gamePrice * _discountRate) / 100));

            return(_discount);
        }
        public ActionResult AddHotelToDestination(AddHotelSpecialOffer model)
        {
            SpecialOffer      specialOffer = db.SpecialOffers.Include(s => s.hotels).FirstOrDefault(s => s.Id == model.SpecialOfferId);
            HotelSpecialOffer hotel        = db.HotelSpecialOffers.Include(s => s.arrangementPrices).Include(s => s.specialOffer).FirstOrDefault(h => h.Id == model.HotelId);

            specialOffer.hotels.Add(hotel);
            db.SaveChanges();
            return(RedirectToAction("Details", new { id = model.SpecialOfferId }));
        }
        // PUT api/awbuildversion/5
        public void Put(SpecialOffer value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                    adventureWorks_BC.SpecialOfferDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.SpecialOfferUpdate(value);
            }
        }
Beispiel #32
0
        public void Navigation_fixup_is_non_destructive_to_existing_graphs()
        {
            using (var context = new FixupContext())
            {
                var category11 = new Category { Id = 11 };
                var category12 = new Category { Id = 12 };
                var category13 = new Category { Id = 13 };

                var product21 = new Product { Id = 21, CategoryId = 11, Category = category11 };
                var product22 = new Product { Id = 22, CategoryId = 11, Category = category11 };
                var product23 = new Product { Id = 23, CategoryId = 11, Category = category11 };
                var product24 = new Product { Id = 24, CategoryId = 12, Category = category12 };
                var product25 = new Product { Id = 25, CategoryId = 12, Category = category12 };

                category11.Products.Add(product21);
                category11.Products.Add(product22);
                category11.Products.Add(product23);
                category12.Products.Add(product24);
                category12.Products.Add(product25);

                var specialOffer31 = new SpecialOffer { Id = 31, ProductId = 22, Product = product22 };
                var specialOffer32 = new SpecialOffer { Id = 32, ProductId = 22, Product = product22 };
                var specialOffer33 = new SpecialOffer { Id = 33, ProductId = 24, Product = product24 };
                var specialOffer34 = new SpecialOffer { Id = 34, ProductId = 24, Product = product24 };
                var specialOffer35 = new SpecialOffer { Id = 35, ProductId = 24, Product = product24 };

                product22.SpecialOffers.Add(specialOffer31);
                product22.SpecialOffers.Add(specialOffer32);
                product24.SpecialOffers.Add(specialOffer33);
                product24.SpecialOffers.Add(specialOffer34);
                product24.SpecialOffers.Add(specialOffer35);

                context.Add(category11);
                AssertAllFixedUp(context);
                context.Add(category12);
                AssertAllFixedUp(context);
                context.Add(category13);
                AssertAllFixedUp(context);

                context.Add(product21);
                AssertAllFixedUp(context);
                context.Add(product22);
                AssertAllFixedUp(context);
                context.Add(product23);
                AssertAllFixedUp(context);
                context.Add(product24);
                AssertAllFixedUp(context);
                context.Add(product25);
                AssertAllFixedUp(context);

                context.Add(specialOffer31);
                AssertAllFixedUp(context);
                context.Add(specialOffer32);
                AssertAllFixedUp(context);
                context.Add(specialOffer33);
                AssertAllFixedUp(context);
                context.Add(specialOffer34);
                AssertAllFixedUp(context);
                context.Add(specialOffer35);
                AssertAllFixedUp(context);

                Assert.Equal(3, category11.Products.Count);
                Assert.Equal(2, category12.Products.Count);
                Assert.Equal(0, category13.Products.Count);

                Assert.Equal(0, product21.SpecialOffers.Count);
                Assert.Equal(2, product22.SpecialOffers.Count);
                Assert.Equal(0, product23.SpecialOffers.Count);
                Assert.Equal(3, product24.SpecialOffers.Count);
                Assert.Equal(0, product25.SpecialOffers.Count);

                Assert.Equal(3, context.ChangeTracker.Entries<Category>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<Product>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<SpecialOffer>().Count());
            }
        }
 // POST api/awbuildversion
 public void Post(SpecialOffer value)
 {
     adventureWorks_BC.SpecialOfferAdd(value);
 }
 /// <summary>
 /// There are no comments for SpecialOffer in the schema.
 /// </summary>
 public void AddToSpecialOffer(SpecialOffer specialOffer)
 {
     base.AddObject("SpecialOffer", specialOffer);
 }
 /// <summary>
 /// Create a new SpecialOffer object.
 /// </summary>
 /// <param name="specialOfferID">Initial value of SpecialOfferID.</param>
 /// <param name="description">Initial value of Description.</param>
 /// <param name="discountPct">Initial value of DiscountPct.</param>
 /// <param name="type">Initial value of Type.</param>
 /// <param name="category">Initial value of Category.</param>
 /// <param name="startDate">Initial value of StartDate.</param>
 /// <param name="endDate">Initial value of EndDate.</param>
 /// <param name="minQty">Initial value of MinQty.</param>
 /// <param name="rowguid">Initial value of rowguid.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static SpecialOffer CreateSpecialOffer(int specialOfferID, string description, decimal discountPct, string type, string category, global::System.DateTime startDate, global::System.DateTime endDate, int minQty, global::System.Guid rowguid, global::System.DateTime modifiedDate)
 {
     SpecialOffer specialOffer = new SpecialOffer();
     specialOffer.SpecialOfferID = specialOfferID;
     specialOffer.Description = description;
     specialOffer.DiscountPct = discountPct;
     specialOffer.Type = type;
     specialOffer.Category = category;
     specialOffer.StartDate = startDate;
     specialOffer.EndDate = endDate;
     specialOffer.MinQty = minQty;
     specialOffer.rowguid = rowguid;
     specialOffer.ModifiedDate = modifiedDate;
     return specialOffer;
 }