/// <summary>
 /// Checks FindItem to make sure it returns null correctly if Item quantity is too high
 /// </summary>
 public void WrongItemShouldNotBeFound()
 {
     using (var context = new Entity.FannerDogsDBContext(options))
     {
         IRepo            _repoDS    = new Repo(context);
         Model.DogManager dogManager = new Model.DogManager(1234567890, "Test, TX", "Texas Toaster");
         _repoDS.AddManager
         (
             dogManager
         );
         Model.StoreLocation storeLocation = new Model.StoreLocation("Test, TX", "Test Dogs");
         _repoDS.AddStoreLocation(
             storeLocation,
             dogManager
             );
         Model.Dog dog = new Model.Dog("Special Breed", 'f', 1000);
         _repoDS.AddItem(
             storeLocation,
             dog,
             5
             );
         Model.Item item = _repoDS.FindItem(
             storeLocation,
             dog,
             20
             );
         bool itemNotThere = (item == null);
         bool expected     = true;
         Assert.Equal(itemNotThere, expected);
     }
 }
 /// <summary>
 /// Makes sure store inventory is being updated
 /// </summary>
 public void AddItemShouldBeInStoreInventory()
 {
     using (var context = new Entity.FannerDogsDBContext(options))
     {
         IRepo            _repoDS    = new Repo(context);
         Model.DogManager dogManager = new Model.DogManager(1234567890, "Test, TX", "Texas Toaster");
         _repoDS.AddManager
         (
             dogManager
         );
         Model.StoreLocation storeLocation = new Model.StoreLocation("Test, TX", "Test Dogs");
         _repoDS.AddStoreLocation(
             storeLocation,
             dogManager
             );
         Model.Dog dog = new Model.Dog("Special Breed", 'f', 1000);
         _repoDS.AddItem(
             storeLocation,
             dog,
             5
             );
         List <Model.Item> items = _repoDS.GetStoreInventory(
             storeLocation.Address,
             storeLocation.Location
             );
         int expected = 1;
         Assert.Equal(items.Count(), expected);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Method to add store location to the file. Adds a store to a file and returns
        /// the added store.
        /// </summary>
        /// <param name="store">StoreLocation to add to memory</param>
        // <returns>Return added StoreLocation</returns>
        public Model.StoreLocation AddStoreLocation(Model.StoreLocation store, Model.DogManager dogManager)
        {
            try{
                Entity.DogStore dogStore = new Entity.DogStore();
                dogStore.StoreName    = store.Location;
                dogStore.StoreAddress = store.Address;
                _context.DogStores.Add(
                    dogStore
                    );
                Entity.ManagesStore managesStore = new Entity.ManagesStore();

                _context.SaveChanges();
                Entity.DogStore dS = (
                    from DogStore in _context.DogStores where
                    DogStore.StoreAddress == dogStore.StoreAddress && DogStore.StoreName == dogStore.StoreName
                    select DogStore
                    ).Single();
                managesStore.ManagerId = dogManager.PhoneNumber;
                managesStore.StoreId   = dS.Id;
                _context.ManagesStores.Add(managesStore);
                _context.SaveChanges();
            }
            catch (Exception ex) {
                Log.Error(ex.Message + "error encountered in AddStoreLocation, this shouldn't happen");
            }
            return(store);
        }
 /// <summary>
 /// Checks AddStoreLocation and FindStore
 /// </summary>
 public void AddStoreLocationAddsStore()
 {
     using (var context = new Entity.FannerDogsDBContext(options))
     {
         IRepo            _repoDS    = new Repo(context);
         Model.DogManager dogManager = new Model.DogManager(1234567890, "Test, TX", "Texas Toaster");
         _repoDS.AddManager
         (
             dogManager
         );
         _repoDS.AddStoreLocation(
             new Model.StoreLocation("Test, TX", "Test Dogs"),
             dogManager
             );
         Model.StoreLocation store = _repoDS.FindStore("Test, TX", "Test Dogs");
         bool storeThere           = (store != null);
         bool expected             = true;
         Assert.Equal(storeThere, expected);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Takes in address and storelocation of order history you're looking for and a special option
        /// parameter where user has inputted the query they wish to perform
        /// </summary>
        /// <param name="address">address of the store you're looking for orders of</param>
        /// <param name="location">name of the store you're looking for orders of</param>
        /// <param name="option">int where user has specified the query they wish to perform</param>
        /// <returns>List of orders purchased at store</returns>
        public List <DogOrder> FindStoreOrders(string address, string location, int option)
        {
            Model.StoreLocation    store     = FindStore(address, location);
            List <Entity.DogOrder> dogOrders = new List <Entity.DogOrder>();

            switch (option)
            {
            case 1:
                dogOrders = (
                    from DogOrder in _context.DogOrders where
                    DogOrder.StoreId == store.id
                    orderby DogOrder.DateOrder ascending
                    select DogOrder
                    ).ToList();
                break;

            case 2:
                dogOrders = (
                    from DogOrder in _context.DogOrders where
                    DogOrder.StoreId == store.id
                    orderby DogOrder.DateOrder descending
                    select DogOrder
                    ).ToList();
                break;

            case 3:
                dogOrders = (
                    from DogOrder in _context.DogOrders where
                    DogOrder.StoreId == store.id
                    orderby DogOrder.Total ascending
                    select DogOrder
                    ).ToList();
                break;

            case 4:
                dogOrders = (
                    from DogOrder in _context.DogOrders where
                    DogOrder.StoreId == store.id
                    orderby DogOrder.Total descending
                    select DogOrder
                    ).ToList();
                break;

            default:
                return(null);
            }
            Model.DogBuyer          dogBuyer;
            List <Entity.OrderItem> orderItems;
            List <Model.DogOrder>   returnOrders = new List <Model.DogOrder>();

            Model.DogOrder returnOrder;
            Entity.Dog     dog;
            foreach (Entity.DogOrder dogOrder in dogOrders)
            {
                dogBuyer   = FindBuyer(dogOrder.BuyerId);
                orderItems = (
                    from OrderItem in _context.OrderItems where
                    OrderItem.OrderId == dogOrder.Id
                    select OrderItem
                    ).ToList();
                returnOrder = new DogOrder(
                    dogBuyer,
                    dogOrder.Total,
                    store
                    );
                returnOrder.OrderDate = dogOrder.DateOrder;
                foreach (Entity.OrderItem orderItem in orderItems)
                {
                    dog = (
                        from Dog in _context.Dogs where
                        Dog.ItemId == orderItem.DogId
                        select Dog
                        ).Single();
                    returnOrder.AddItemToOrder(new Model.OrderItem(
                                                   new Model.Dog(
                                                       dog.Breed,
                                                       dog.Gender.ToCharArray()[0],
                                                       dog.Price
                                                       ),
                                                   orderItem.Quantity.Value
                                                   ));
                }
                returnOrders.Add(returnOrder);
            }
            return(returnOrders);
        }
 public bool Equals(StoreLocation store)
 {
     return(this.Address.Equals(store.Address) && this.Location.Equals(store.Location));
 }