Example #1
0
        public void CanWriteToDb()
        {
            string tenantId = "Contoso Inc.";
            string id = Guid.NewGuid().ToString();
            string desc = "do something awesome";

            var doc = new Item { Id = id, Description = desc };

            ItemRepository repo = new ItemRepository(this.client, this.database.Id);
            Item created = repo.Create(doc, tenantId).Result;
            Assert.IsNotNull(created);
            Assert.AreEqual(created.Description, desc);

            tenantId = "Litware Inc.";
            id = Guid.NewGuid().ToString();
            desc = "do something awesome";

            doc = new Item { Id = id, Description = desc };

            created = repo.Create(doc, tenantId).Result;
            Assert.IsNotNull(created);
            Assert.AreEqual(created.Description, desc);

            tenantId = "Adventure Works";
            id = Guid.NewGuid().ToString();
            desc = "do something awesome";

            doc = new Item { Id = id, Description = desc };

            created = repo.Create(doc, tenantId).Result;
            Assert.IsNotNull(created);
            Assert.AreEqual(created.Description, desc);
        }
Example #2
0
 static void Main(string[] args)
 {
     IItemRepository repository = new ItemRepository();
     var item = repository.GetItem(1);
     item.Value = "one";
     repository.Update(item);
 }
Example #3
0
 /// <summary>Creates an instance for the given language.</summary>
 /// <param name="culture">The culture.</param>
 /// <returns>A repository.</returns>
 public IItemRepository ForCulture(CultureInfo culture)
 {
     Contract.Ensures(Contract.Result<IItemRepository>() != null);
     IItemRepository repository = new ItemRepository(this.serviceClient);
     repository.Culture = culture;
     return repository;
 }
Example #4
0
 public ItemManager(
     ItemRepository repository,
     ITradingPostApiWrapper apiWrapper)
 {
     _repository = repository;
     _apiWrapper = apiWrapper;
 }
Example #5
0
        public MultiplayerServer()
        {
            var reader = new PacketReader();
            PacketReader = reader;
            Clients = new List<IRemoteClient>();
            EnvironmentWorker = new Timer(DoEnvironment);
            PacketHandlers = new PacketHandler[0x100];
            Worlds = new List<IWorld>();
            EntityManagers = new List<IEntityManager>();
            LogProviders = new List<ILogProvider>();
            Scheduler = new EventScheduler(this);
            var blockRepository = new BlockRepository();
            blockRepository.DiscoverBlockProviders();
            BlockRepository = blockRepository;
            var itemRepository = new ItemRepository();
            itemRepository.DiscoverItemProviders();
            ItemRepository = itemRepository;
            BlockProvider.ItemRepository = ItemRepository;
            BlockProvider.BlockRepository = BlockRepository;
            var craftingRepository = new CraftingRepository();
            craftingRepository.DiscoverRecipes();
            CraftingRepository = craftingRepository;
            PendingBlockUpdates = new Queue<BlockUpdate>();
            EnableClientLogging = false;
            QueryProtocol = new TrueCraft.QueryProtocol(this);
            WorldLighters = new List<WorldLighting>();

            AccessConfiguration = Configuration.LoadConfiguration<AccessConfiguration>("access.yaml");

            reader.RegisterCorePackets();
            Handlers.PacketHandlers.RegisterHandlers(this);
        }
Example #6
0
        public void ProcessContent(IContentPersister persister)
        {
            using (var db = new GameDatabaseContext())
            {
                var repo = new ItemRepository(db);
                var items = repo.GetAll();

                foreach (var item in items)
                {

                    // Save out properties we want to a new object and then persist
                    dynamic persistable = new ExpandoObject();

                    Console.WriteLine("Processing item with ID {0}", item.Id);

                    persistable.id = item.Id;
                    persistable.name = item.Name;
                    persistable.type = item.Type;
                    persistable.equipSlot = item.EquipmentSlot;
                    persistable.description = item.Description;
                    persistable.restoreHp = item.RestoreHp;
                    persistable.iconId = item.IconId;

                    persister.Persist(persistable, "\\items\\{0}.json".FormatWith(item.Id));

                }

            }
        }
 private static ItemRepository CreateRepository()
 {
     var db = "test.db";
     if (File.Exists(db)) File.Delete(db);
     var repository = new ItemRepository(db);
     repository.MigrateSchema();
     return repository;
 }
 public StockInformationRepository()
 {
     _itemRepository = new ItemRepository();
     _unitOfIssueRepository = new UnitRepository();
     _manufacturerRepository = new ManufacturerRepository();
     _physicalStoreRepository = new PhysicalStoreRepository();
     _activityRepository = new ActivityRepository();
 }
        public void ItemRepository_Restore()
        {
            var itemRepository = new ItemRepository();

            var items = itemRepository.Restore();

            Assert.IsNotNull(items);
            Assert.IsTrue(items.Count > 0);
        }
Example #10
0
        protected override void Save()
        {
            using (var db = new GameDatabaseContext())
            {
                var ContentTemplate = this.ContentTemplate as ItemTemplate;
                var repository = new ItemRepository(db);
                repository.Update(ContentTemplate, ContentTemplate.Id);
            }

            base.Save();
        }
Example #11
0
 public Collector(IDatabaseContext context)
 {
     _context = context;   
     Items = new ItemRepository(_context);
     Ingredients = new IngredientRepository(_context);
     Foodplans = new FoodplanRepository(_context);
     Shoppinglists = new ShoppinglistRepository(_context);
     Recipes = new RecipeRepository(_context);
     Users = new UserRepository(_context); 
             
 }
Example #12
0
        public IHttpActionResult NewItem()
        {
            using (var context = new GameDatabaseContext())
            {

                var repo = new ItemRepository(context);
                var item = repo.Add(new ItemTemplate(0, "New Item", "", ItemType.FieldItem , 0, true, 0));

                return Ok(item);
            }
        }
Example #13
0
        public IHttpActionResult SaveItem(ItemTemplate item, int id)
        {
            using (var context = new GameDatabaseContext())
            {

                var repo = new ItemRepository(context);
                repo.Update(item, id);

                return Ok();
            }
        }
Example #14
0
        public void ItemWithoutIconShouldBeAdded()
        {
            ItemRepository repository = new ItemRepository(new TestDatabaseProvider());

            Item item = TestDataProvider.GetItem();
            repository.Save(item);

            Item dbItem = repository.Get(item.Id);

            Assert.NotNull(dbItem);
            Assert.Equal(item.Id, dbItem.Id);
        }
Example #15
0
        public void ItemShouldBeDeleted()
        {
            ItemRepository repository = new ItemRepository(new TestDatabaseProvider());

            Item item = TestDataProvider.GetItem();
            repository.Save(item);

            repository.Delete(item);

            Item dbItem = repository.Get(item.Id);
            Assert.Null(dbItem);
        }
 public RequestRepository()
 {
     _clientRepository = new ClientRepository();
     _itemRepository = new ItemRepository();
     _unitOfIssueRepository = new UnitRepository();
     _modeService = new ModeService();
     _paymentTermService = new PaymentTermRepository();
     _orderStatusService = new OrderStatusService();
     _manufacturerRepository = new ManufacturerRepository();
     _physicalStoreRepository = new PhysicalStoreRepository();
     _activityRepository = new ActivityRepository();
 }
        public void ItemRepository__ConvertToJson()
        {
            var item = new Item()
            {
                Title = "Test Item"
            };

            var itemRepository = new ItemRepository();

            var stringItem = itemRepository.ConvertToJson(new[] { item });

            Assert.IsFalse(string.IsNullOrWhiteSpace(stringItem));
        }
        public void AtualizarItemDaColecaoDoUsuario(Int32 id, String titulo,
            String descricao, Int32 ano, String nomeAutor, Int32 tpItem)
        {
            //tratando o nome do autor;
            String[] _nomeAutor = nomeAutor.Split(new char[] { ' ' });

            //passando os parametros para a fábrica montar o objeto.
            Item item = new ItemFactory().createItem(id, titulo, descricao, ano, _nomeAutor, tpItem);

            IItemRepository repository = new ItemRepository();
            repository.Update(item);
            repository.Save();
        }
Example #19
0
        public void ItemShouldBeUpdated()
        {
            ItemRepository repository = new ItemRepository(new TestDatabaseProvider());

            Item item = TestDataProvider.GetItem();
            repository.Save(item);

            // update name
            item.Name = "new item name";
            repository.Save(item);

            Item dbItem = repository.Get(item.Id);
            Assert.NotNull(dbItem);
            Assert.Equal(item.Name, dbItem.Name);
        }
        public void ItemRepository_Store()
        {
            var item1 = new Item()
            {
                Title = "Test Item 1"
            };
            var item2 = new Item()
            {
                Title = "Test Item 2"
            };

            var itemRepository = new ItemRepository();

            itemRepository.Store(new[] { item1, item2 });
        }
Example #21
0
        public void CanReadFromDb()
        {
            string tenantId = "Contoso Inc.";
            string id = Guid.NewGuid().ToString();
            string desc = "do something awesome";

            var doc = new Item { Id = id, Description = desc };

            ItemRepository repo = new ItemRepository(this.client, this.database.Id);
            Item created = repo.Create(doc, tenantId).Result;

            Item read = repo.Find(tenantId, item => item.Id == id).FirstOrDefault();

            Assert.IsNotNull(read);
            Assert.AreEqual(created.Id, read.Id);
            Assert.AreEqual(created.Description, read.Description);
        }
Example #22
0
        public void ItemRepository_Add_IsNotNullWhenGet()
        {
            var dbData = new DalItem()
            {
                Id = 100,
                Comment = "adfaf",
                Completed = true,
                Title = "sfsdf"
            };
            var dbSetMock = new Mock<DbSet<OrmItem>>();
            var dbContextMock = new Mock<EntityModelContext>();
            dbContextMock.Setup(x => x.Set<OrmItem>()).Returns(dbSetMock.Object);

            var repo = new ItemRepository(dbContextMock.Object);
            repo.Add(dbData);
            Assert.IsNotNull(repo.Get(100));
        }
        public void InserirItemNaColecaoDoUsuario(String titulo, String descricao, 
            Int32 ano, String nomeAutor, Int32 tpItem, Int32 idUser)
        {
            String[] _nomeAutor = nomeAutor.Split(new char[] { ' ' });
            Item item = new ItemFactory().createItem(null, titulo, descricao, ano, _nomeAutor, tpItem);

            IItemRepository repository = new ItemRepository();
            IUsuarioRepository usrRepository = new UsuarioRepository();

            //buscar o usuário para setar no item
            Usuario usr = usrRepository.FindById(idUser);

            //setando o usuário no item para a referencia da fk.
            item._Usuario = usr;

            repository.Create(item);
            repository.Save();
        }
 public SimbaToursEastAfricaUnitOfWork(
     AbstractRepository <Address> addressRepository,
     AbstractRepository <Destination> destinationRepository,
     AbstractRepository <Driver> driverRepository,
     AbstractRepository <HotelBooking> hotelBookingRepository,
     AbstractRepository <InAndOutBoundAirTravel> inAndOutBoundAirTravelRepository,
     AbstractRepository <InternalVehicleTravel> internalVehicleTravelRepository,
     AbstractRepository <Invoice> invoiceRepository,
     AbstractRepository <Item> itemRepository,
     AbstractRepository <Itinary> itinaryRepository,
     AbstractRepository <Laguage> laguageRepository,
     AbstractRepository <Location> locationRepository,
     AbstractRepository <Meal> mealRepository,
     AbstractRepository <Schedule> scheduleRepository,
     AbstractRepository <TourClient> tourClientRepository,
     AbstractRepository <Vehicle> vehicleRepository,
     AbstractRepository <SchedulesPricing> schedulesPricingRepository,
     AbstractRepository <MealPricing> mealPricingRepository,
     AbstractRepository <DealsPricing> dealsPricingRepository,
     AbstractRepository <LaguagePricing> laguagePricingRepository,
     AbstractRepository <HotelPricing> hotelPricingRepostory,
     AbstractRepository <Hotel> hotelRepostory,
     AbstractRepository <TransportPricing> transportPricingRepository,
     Microsoft.EntityFrameworkCore.DbContext simbaToursEastAfricaDbContext)
 {
     SimbaToursEastAfricaDbContext = simbaToursEastAfricaDbContext as SimbaToursEastAfricaDbContext;
     _addressRepository            = addressRepository as AddressRepository;
     _addressRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _destinationRepository = destinationRepository as DestinationRepository;
     _destinationRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _driverRepository = driverRepository as DriverRepository;
     _driverRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _hotelBookingRepository = hotelBookingRepository as HotelBookingRepository;
     _hotelBookingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _inAndOutBoundAirTravelRepository = inAndOutBoundAirTravelRepository as InAndOutBoundAirTravelRepository;
     _inAndOutBoundAirTravelRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _internalVehicleTravelRepository = internalVehicleTravelRepository as InternalVehicleTravelRepository;
     _internalVehicleTravelRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _invoiceRepository = invoiceRepository as InvoiceRepository;
     _invoiceRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _itemRepository = itemRepository as ItemRepository;
     _itemRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _itinaryRepository = itinaryRepository as ItinaryRepository;
     _itinaryRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _laguageRepository = laguageRepository as LaguageRepository;
     _laguageRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _locationRepository = locationRepository as LocationRepository;
     _locationRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _mealRepository = mealRepository as MealRepository;
     _mealRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _scheduleRepository = scheduleRepository as ScheduleRepository;
     _scheduleRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _tourClientRepository = tourClientRepository as TourClientRepository;
     _tourClientRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _vehicleRepository = vehicleRepository as VehicleRepository;
     _vehicleRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _mealsPricingRepository = mealPricingRepository as MealsPricingRepository;
     _mealsPricingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _dealsPricingRepository = dealsPricingRepository as DealsPricingRepository;
     _dealsPricingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _laguagePricingRepository = laguagePricingRepository as LaguagePricingRepository;
     _laguagePricingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _schedulesPricingRepository = schedulesPricingRepository as SchedulesPricingRepository;
     _schedulesPricingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _hotelPricingRepository = hotelPricingRepostory as HotelPricingRepository;
     _hotelPricingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _hotelRepository = hotelRepostory as HotelRepository;
     _hotelRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
     _transportPricingRepository = transportPricingRepository as TransportPricingRepository;
     _transportPricingRepository.SimbaToursEastAfricaDbContext = SimbaToursEastAfricaDbContext;
 }
 public ItemManager(UnitOfWorkManager unitOfWorkManager)
 {
     itemRepository = new ItemRepository(unitOfWorkManager.UnitOfWork);
 }
 public void TestInitialize()
 {
     context        = new ApplicationDbContext();
     itemService    = new ItemService(context);
     itemRepository = new ItemRepository(context);
 }
Example #27
0
        public IHttpActionResult GetAllItems()
        {
            var items = ItemRepository.GetAllItems();

            return(Ok(items));
        }
 public FindItemQueryHandler(ItemRepository repository)
 {
     _repository = repository;
 }
Example #29
0
        /// <summary>
        /// Validates the children internal.
        /// </summary>
        /// <param name="progress">The progress.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <param name="refreshChildMetadata">if set to <c>true</c> [refresh child metadata].</param>
        /// <param name="refreshOptions">The refresh options.</param>
        /// <param name="directoryService">The directory service.</param>
        /// <returns>Task.</returns>
        protected async virtual Task ValidateChildrenInternal(IProgress <double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
        {
            var locationType = LocationType;

            cancellationToken.ThrowIfCancellationRequested();

            var validChildren = new List <BaseItem>();

            if (locationType != LocationType.Remote && locationType != LocationType.Virtual)
            {
                IEnumerable <BaseItem> nonCachedChildren;

                try
                {
                    nonCachedChildren = GetNonCachedChildren(directoryService);
                }
                catch (IOException ex)
                {
                    nonCachedChildren = new BaseItem[] { };

                    Logger.ErrorException("Error getting file system entries for {0}", ex, Path);
                }

                if (nonCachedChildren == null)
                {
                    return;                            //nothing to validate
                }
                progress.Report(5);

                //build a dictionary of the current children we have now by Id so we can compare quickly and easily
                var currentChildren = GetActualChildrenDictionary();

                //create a list for our validated children
                var newItems = new List <BaseItem>();

                cancellationToken.ThrowIfCancellationRequested();

                foreach (var child in nonCachedChildren)
                {
                    BaseItem currentChild;

                    if (currentChildren.TryGetValue(child.Id, out currentChild))
                    {
                        if (IsValidFromResolver(currentChild, child))
                        {
                            var currentChildLocationType = currentChild.LocationType;
                            if (currentChildLocationType != LocationType.Remote &&
                                currentChildLocationType != LocationType.Virtual)
                            {
                                currentChild.DateModified = child.DateModified;
                            }

                            currentChild.IsOffline = false;
                            validChildren.Add(currentChild);
                        }
                        else
                        {
                            validChildren.Add(child);
                        }
                    }
                    else
                    {
                        // Brand new item - needs to be added
                        newItems.Add(child);
                        validChildren.Add(child);
                    }
                }

                // If any items were added or removed....
                if (newItems.Count > 0 || currentChildren.Count != validChildren.Count)
                {
                    // That's all the new and changed ones - now see if there are any that are missing
                    var itemsRemoved   = currentChildren.Values.Except(validChildren).ToList();
                    var actualRemovals = new List <BaseItem>();

                    foreach (var item in itemsRemoved)
                    {
                        if (item.LocationType == LocationType.Virtual ||
                            item.LocationType == LocationType.Remote)
                        {
                            // Don't remove these because there's no way to accurately validate them.
                            validChildren.Add(item);
                        }

                        else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path))
                        {
                            item.IsOffline = true;
                            validChildren.Add(item);
                        }
                        else
                        {
                            item.IsOffline = false;
                            actualRemovals.Add(item);
                        }
                    }

                    if (actualRemovals.Count > 0)
                    {
                        RemoveChildrenInternal(actualRemovals);

                        foreach (var item in actualRemovals)
                        {
                            LibraryManager.ReportItemRemoved(item);
                        }
                    }

                    await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false);

                    AddChildrenInternal(newItems);

                    await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
                }
            }

            progress.Report(10);

            cancellationToken.ThrowIfCancellationRequested();

            if (recursive)
            {
                await ValidateSubFolders(ActualChildren.OfType <Folder>().ToList(), directoryService, progress, cancellationToken).ConfigureAwait(false);
            }

            progress.Report(20);

            if (refreshChildMetadata)
            {
                var container = this as IMetadataContainer;

                var innerProgress = new ActionableProgress <double>();

                innerProgress.RegisterAction(p => progress.Report((.80 * p) + 20));

                if (container != null)
                {
                    await container.RefreshAllMetadata(refreshOptions, innerProgress, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    await RefreshMetadataRecursive(refreshOptions, recursive, innerProgress, cancellationToken);
                }
            }

            progress.Report(100);
        }
Example #30
0
        static void Main(string[] args)
        {
            for (int i = 0; i < MyItems; i++)
            {
                try
                {
                    if (MyItems == 1)
                    {
                        Console.WriteLine("Welcome to the Store....");
                        Console.Write("Please scan the item code (Enter item Id):");
                    }
                    else if (MyItems >= 1)
                    {
                        Console.Write("Please scan the next item code (Enter item Id):");
                    }

                    string inputItem = Console.ReadLine();

                    if (Int32.TryParse(inputItem, out int num))// (foo, out int number1))
                    {
                        ItemRepository itemsRep = new ItemRepository();
                        Item           finditem = itemsRep.Retrieve(num);
                        if (finditem == null)
                        {
                            Console.WriteLine("Input is not a valid item Id!");
                        }
                        else
                        {
                            Console.WriteLine("Item Name : " + finditem.Name + " --  Item Cost : " + finditem.Cost.ToString() + "$");
                            Console.Write("Enter the Quantity in " + finditem.IType.Unit + " : ");
                            string inputQuantity = Console.ReadLine();

                            double Qnum       = 0;
                            bool   validInput = true;
                            // To check the item type and user input
                            if (finditem.IType.Type == "Count")
                            {
                                if (Int32.TryParse(inputQuantity, out int inum))
                                {
                                    validInput = true;
                                    Qnum       = inum;
                                }
                                else
                                {
                                    validInput = false;
                                }
                            }
                            else
                            {
                                if (double.TryParse(inputQuantity, out Qnum))
                                {
                                    validInput = true;
                                }
                                else
                                {
                                    validInput = false;
                                }
                            }
                            if (validInput && Qnum > 0)
                            {
                                DiscountRepository desCop  = new DiscountRepository();
                                DiscountCoupon     findCop = desCop.Retrieve(num);
                                //  For no discount items
                                if (findCop == null || findCop.CouponID == 0)
                                {
                                    //Console.WriteLine("No Discount");
                                    // To calculate Total quantity by iterating through shopping cart if needed
                                    double totalQty = CashRegisterService.CalculateQty(Qnum, BilledItesmDict, finditem);
                                    // Adding item to shopping cart Dictionary
                                    CashRegisterService.CheckItemAndAdd(BilledItesmDict, CashRegisterService.CreateItem(finditem, totalQty, "-", totalQty * finditem.Cost), finditem);

                                    CashRegisterService.DisplayBill(BilledItesmDict);
                                }
                                else
                                {
                                    Console.WriteLine("Discount Value:" + findCop.CDetails.CDiscountVal.ToString());

                                    BilledItem billItem = new BilledItem
                                    {
                                        ItmName     = finditem.Name,
                                        ItmQuantity = Qnum,
                                        ItmCost     = finditem.Cost
                                    };

                                    if (finditem.IType.Type == "Count")
                                    {
                                        int FreeItems = 0;
                                        try
                                        {
                                            FreeItems = Convert.ToInt32(Qnum) / findCop.CDetails.CMinVal;
                                        }
                                        catch (Exception)
                                        {
                                            Console.WriteLine("Exception occurred while calculating free items");
                                        }
                                        if (FreeItems > 0)
                                        {
                                            // To Calculate Discount for Qunatity based items
                                            CashRegisterService.ApplyDiscount(BilledItesmDict, findCop, finditem, billItem, Qnum);
                                        }
                                        else
                                        {
                                            billItem.DisCntDetails = "-";
                                            billItem.TotCost       = Qnum * finditem.Cost;
                                        }
                                    }
                                    else
                                    {
                                        if (Qnum >= findCop.CDetails.CMinVal)
                                        {
                                            // To Calculate Discount based on percentage
                                            CashRegisterService.ApplyDiscountPct(BilledItesmDict, findCop, finditem, billItem, Qnum);
                                        }
                                        else
                                        {
                                            billItem.DisCntDetails = "-";
                                            billItem.TotCost       = Qnum * finditem.Cost;
                                        }
                                    }
                                    // Adding item to shopping cart Dictionary
                                    CashRegisterService.CheckItemAndAdd(BilledItesmDict, billItem, finditem);
                                    CashRegisterService.DisplayBill(BilledItesmDict);
                                }
                            }
                            else
                            {
                                Console.WriteLine("Input is not a valid item Id!");
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Input is not a valid item Id!");
                    }
                    ContinuePurchase();
                }
                catch (FormatException e)
                {
                    Console.WriteLine("\n\n\n\n\n{0}\n\n\n\n", e.Message);
                    ContinuePurchase();
                }
            }
        }
Example #31
0
 public GameObjectBase GetFromDatabaseByID(int resourceID, GameObjectTypeEnum gameResourceType)
 {
     if (gameResourceType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #32
0
 /// <summary>
 /// Returns True if an object exists in the database.
 /// Returns False if an object does not exist in the database.
 /// </summary>
 /// <param name="resref">The resource reference to search for.</param>
 /// <param name="resourceType">The resource type to look for.</param>
 /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
 /// <returns></returns>
 public bool DoesObjectExistInDatabase(string resref, GameObjectTypeEnum resourceType, string connectionString = "")
 {
     if (resourceType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #33
0
 public void MigratePlayState(ItemRepository repo)
 {
     throw new NotImplementedException();
 }
 public void MigratePlayState(ItemRepository repo)
 {
     SafeAction(() => repository.MigratePlayState(repo));
 }
 public void MigrateDisplayPrefs(ItemRepository repo)
 {
     SafeAction(() => repository.MigrateDisplayPrefs(repo));
 }
 public UnitTest1()
 {
     _repo    = new Mock <IItemRepository>();
     _context = new Mock <ShopDBContext>();
     obj      = new ItemRepository(_context.Object);
 }
Example #37
0
 /// <summary>
 /// Get our children from the repo - stubbed for now
 /// </summary>
 /// <returns>IEnumerable{BaseItem}.</returns>
 protected IEnumerable <BaseItem> GetCachedChildren()
 {
     return(ItemRepository.GetChildren(Id).Select(RetrieveChild).Where(i => i != null));
 }
 public void MigrateDisplayPrefs(ItemRepository repo)
 {
     throw new NotImplementedException();
 }
Example #39
0
        public ActionResult ItemPost()
        {
            try
            {
                // Create a list to hold list of items
                var itemList = new List <Item>();

                // Loop through the request.forms
                for (var i = 0; i <= Request.Form.Count; i++)
                {
                    var name    = Request.Form["ItemName[" + i + "]"];
                    var qty     = Request.Form["Quantity[" + i + "]"];
                    var size    = Request.Form["Size[" + i + "]"];
                    var marking = Request.Form["Marking[" + i + "]"];

                    if (name == null || size == null || marking == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(qty))
                    {
                        qty = "0";
                    }

                    var itemExist = BaseRepository.OimsDataContext.Items.Any(n => n.I_Name == name);
                    if (!itemExist)
                    {
                        var item = new Item {
                            I_Name = name, I_Quantity = float.Parse(qty, CultureInfo.InvariantCulture.NumberFormat), Size = size, Marking = marking
                        };
                        itemList.Add(item);
                    }
                    else
                    {
                        throw new CustomException(Supervisor.IErrorMsgItemExist);
                    }
                }

                // Save items to database
                if (itemList.Count > 0)
                {
                    // Ref - http://stackoverflow.com/questions/3811464/how-to-get-duplicate-items-from-a-list-using-linq?lq=1
                    // Best - http://stackoverflow.com/questions/1606679/remove-duplicates-in-the-list-using-linq?rq=1
                    var duplicateExist = itemList.GroupBy(x => x).Where(g => g.Count() > 1).Select(g => g.Key).Any();

                    if (duplicateExist)
                    {
                        TempData["ErrorMessage"] = string.Format(Common.ErrorDiv, Supervisor.IErrorMsgSameItem);
                    }
                    else
                    {
                        ItemRepository.SaveItems(itemList);
                        TempData["ConfirmMessage"] = string.Format(Common.ConfirmDiv, Supervisor.IMsgItemCreated);
                    }
                }
                else
                {
                    TempData["ErrorMessage"] = string.Format(Common.ErrorDiv, Common.ErrorMsgBlankFields);
                }
            }
            catch (Exception exc)
            {
                TempData["ErrorMessage"] = string.Format(Common.ErrorDiv, exc.Message);
                Logger.LogError(exc, "Error while saving items from Supervisor zone");
            }

            return(PartialView("_Result"));
        }
 public ItemController()
 {
     this.repo = new ItemRepository();
 }
Example #41
0
 public PriceRuleScript(IUnitOfWork unitOfWork, ExecutionController controller) : base(unitOfWork)
 {
     this.repository          = new ItemRepository(unitOfWork, controller);
     this.ExecutionController = controller;
 }
Example #42
0
        public ActionResult PredefinedItemsGridPartial()
        {
            var model = ItemRepository.GetPredefinedItems();

            return(PartialView("_PredefinedItemsGridPartial", model));
        }
Example #43
0
 public ItemsController(AuctionContext auctionContext)
 {
     _itemRepository    = new ItemRepository(auctionContext);
     _auctionRepository = new AuctionRepository(auctionContext);
 }
Example #44
0
 private void Start()
 {
     ItemsInBag      = new Dictionary <int, int>();
     _ItemRepository = this.FindComponentByObjectTag <ItemRepository>("ItemRepository");
     _GameManager    = GameManager.Instance.GetComponent <GameManager>();;
 }
Example #45
0
 public StockItemController()
 {
     repo = new ItemRepository();
 }
        public ResponsePadrao Post([FromBody] ItemRequest value)
        {
            var lLogin = UsuarioRepository.Login(value.Login, value.Senha);

            return(lLogin.Sucesso ? ItemRepository.NovoItem(value.Item) : lLogin);
        }
Example #47
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="currentTab">The selected tab.</param>
        /// <param name="sortBy">How to sort items.</param>
        /// <param name="quality">The item quality to display.</param>
        /// <param name="search">The search term to prepopulate.</param>
        /// <param name="i18n">Provides translations for the mod.</param>
        /// <param name="itemRepository">Provides methods for searching and constructing items.</param>
        public ItemMenu(MenuTab currentTab, ItemSort sortBy, ItemQuality quality, string search, ITranslationHelper i18n, ItemRepository itemRepository)
            : base(null, true, true, 0, -50)
        {
            // initialise
            this.TranslationHelper = i18n;
            this.ItemRepository    = itemRepository;
            this.MovePosition(110, Game1.viewport.Height / 2 - (650 + IClickableMenu.borderWidth * 2) / 2);
            this.CurrentTab      = currentTab;
            this.SortBy          = sortBy;
            this.Quality         = quality;
            this.SpawnableItems  = this.ItemRepository.GetFiltered().Select(p => p.Item).ToArray();
            this.AllowRightClick = true;

            // create search box
            int textWidth = Game1.tileSize * 8;

            this.Textbox = new TextBox(null, null, Game1.dialogueFont, Game1.textColor)
            {
                X        = this.xPositionOnScreen + (this.width / 2) - (textWidth / 2) - Game1.tileSize + 32,
                Y        = this.yPositionOnScreen + (this.height / 2) + Game1.tileSize * 2 + 40,
                Width    = textWidth,
                Height   = Game1.tileSize * 3,
                Selected = false,
                Text     = search
            };
            Game1.keyboardDispatcher.Subscriber = this.Textbox;
            this.TextboxBounds = new Rectangle(this.Textbox.X, this.Textbox.Y, this.Textbox.Width, this.Textbox.Height / 3);

            // create buttons
            this.Title         = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize, this.yPositionOnScreen - Game1.tileSize * 2, Game1.tileSize * 4, Game1.tileSize), i18n.Get("title"));
            this.QualityButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize * 2 + 10, (int)Game1.smallFont.MeasureString(i18n.Get("labels.quality")).X, Game1.tileSize), i18n.Get("labels.quality"));
            this.SortButton    = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.QualityButton.bounds.Width + 40, this.yPositionOnScreen - Game1.tileSize * 2 + 10, Game1.tileSize * 4, Game1.tileSize), this.GetSortLabel(sortBy));
            this.UpArrow       = new ClickableTextureComponent("up-arrow", new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2, this.yPositionOnScreen - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom);
            this.DownArrow     = new ClickableTextureComponent("down-arrow", new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2, this.yPositionOnScreen + this.height / 2 - Game1.tileSize * 2, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);

            // create tabs
            {
                int i = -1;

                int x         = (int)(this.xPositionOnScreen - Game1.tileSize * 5.3f);
                int y         = this.yPositionOnScreen + 10;
                int lblHeight = (int)(Game1.tileSize * 0.9F);

                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.All.ToString(), i18n.Get("tabs.all")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ToolsAndEquipment.ToString(), i18n.Get("tabs.equipment")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.SeedsAndCrops.ToString(), i18n.Get("tabs.crops")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.FishAndBaitAndTrash.ToString(), i18n.Get("tabs.fishing")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ForageAndFruits.ToString(), i18n.Get("tabs.forage")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ArtifactsAndMinerals.ToString(), i18n.Get("tabs.artifacts-and-minerals")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ResourcesAndCrafting.ToString(), i18n.Get("tabs.resources-and-crafting")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ArtisanAndCooking.ToString(), i18n.Get("tabs.artisan-and-cooking")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.AnimalAndMonster.ToString(), i18n.Get("tabs.animal-and-monster")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Decorating.ToString(), i18n.Get("tabs.decorating")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i, Game1.tileSize * 5, Game1.tileSize), MenuTab.Misc.ToString(), i18n.Get("tabs.miscellaneous")));
            }

            // load items
            this.LoadInventory(this.SpawnableItems);
        }
Example #48
0
 /// <summary>Construct an instance.</summary>
 /// <param name="i18n">Provides translations for the mod.</param>
 /// <param name="itemRepository">Provides methods for searching and constructing items.</param>
 public ItemMenu(ITranslationHelper i18n, ItemRepository itemRepository)
     : this(0, 0, ItemQuality.Normal, "", i18n, itemRepository)
 {
 }
        public async Task Delete <T>(string siteId, string id) where T : DataModelBase
        {
            var obj = await ItemRepository.GetItemAsync(siteId, id);

            Delete(obj);
        }
 public void Setup()
 {
     _repo  = new ItemRepository(new EmartDBContext());
     _repo1 = new SellerRepository(new EmartDBContext());
 }
Example #51
0
 public void MigrateDisplayPrefs(ItemRepository repo)
 {
     throw new NotImplementedException();
 }
 public ItemCtr()
 {
     repos = new ItemRepository();
 }
Example #53
0
        /// <summary>
        /// Returns all objects from the database that have a matching resource category.
        /// </summary>
        /// <param name="resourceCategory">The resource category all return values must match</param>
        /// <param name="resourceType">The type of resource to look for.</param>
        /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
        /// <returns></returns>
        public List<GameObjectBase> GetAllFromDatabaseByResourceCategory(Category resourceCategory, GameObjectTypeEnum resourceType, string connectionString = "")
        {
            List<GameObjectBase> retList = new List<GameObjectBase>();

            if (resourceType == GameObjectTypeEnum.Area)
            {
                using (AreaRepository repo = new AreaRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Conversation)
            {
                using (ConversationRepository repo = new ConversationRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Creature)
            {
                using (CreatureRepository repo = new CreatureRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Item)
            {
                using (ItemRepository repo = new ItemRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Placeable)
            {
                using (PlaceableRepository repo = new PlaceableRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Script)
            {
                using (ScriptRepository repo = new ScriptRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Tileset)
            {
                using (TilesetRepository repo = new TilesetRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #54
0
 public CopyController()
 {
     _itemRepository = new ItemRepository(new db());
 }
Example #55
0
 public void UpsertInDatabase(GameObjectBase gameObject, string connectionString = "")
 {
     if (gameObject.GameObjectType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             repo.Upsert(gameObject as Area);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             repo.Upsert(gameObject as Conversation);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             repo.Upsert(gameObject as Creature);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             repo.Upsert(gameObject as Item);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             repo.Upsert(gameObject as Placeable);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             repo.Upsert(gameObject as Script);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             repo.Upsert(gameObject as Tileset);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
 public ItemRepositoryTests(CatalogContextFactory catalogContextFactory)
 {
     _context = catalogContextFactory.ContextInstance;
     _sut     = new ItemRepository(_context);
 }
 public void MigratePlayState(ItemRepository repo)
 {
     throw new NotImplementedException();
 }
Example #58
0
        private void sluItemCode_EditValueChanged(object sender, EventArgs e)
        {
            if (sluItemCode.EditValue == null)
            {
                return;
            }
            int rowHandle = sluItemCodeView.LocateByValue("ITEMCODEID", sluItemCode.EditValue);

            txtItemCode.EditValue = sluItemCodeView.GetRowCellValue(rowHandle, "ITEMCODE");
            isOpenItem            = Convert.ToBoolean(sluItemCodeView.GetRowCellValue(rowHandle, "ISOPENITEM"));
            DataTable dtPrices = new ItemRepository().GetMRPList(sluItemCode.EditValue);

            if (dtPrices.Rows.Count > 1)
            {
                frmMRPSelection mRPSelection = new frmMRPSelection(dtPrices, txtItemCode.EditValue, sluItemCode.Text)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                mRPSelection.ShowDialog();
                if (!mRPSelection._IsSave)
                {
                    ClearItemData();
                    return;
                }

                drSelectedPrice = (mRPSelection.drSelected as DataRowView)?.Row;
            }
            else if (dtPrices.Rows.Count == 1)
            {
                drSelectedPrice = dtPrices.Rows[0];
            }

            if (drSelectedPrice == null)
            {
                return;
            }

            txtMRP.EditValue       = drSelectedPrice["MRP"];
            txtSalePrice.EditValue = drSelectedPrice["SALEPRICE"];
            txtQuantity.EditValue  = 1;
            if (isOpenItem)
            {
                txtWeightInKgs.Enabled = true;
                txtQuantity.EditValue  = 1;
                txtQuantity.Enabled    = false;
            }
            else
            {
                txtWeightInKgs.EditValue = "0.00";
                txtWeightInKgs.Enabled   = false;
                txtQuantity.Enabled      = true;
            }
            if (!isItemScanned)
            {
                if (isOpenItem)
                {
                    txtWeightInKgs.Focus();
                }
                else
                {
                    txtQuantity.Focus();
                }
            }
        }
Example #59
0
 private void SaveItem(object sender, GameObjectSaveEventArgs e)
 {
     using (ItemRepository repo = new ItemRepository())
     {
         repo.Upsert(e.ActiveItem);
     }
 }
Example #60
0
 public SearchController(ApplicationDbContext context)
 {
     repository     = new ItemRepository(context);
     repositoryType = new ItemTypeRepository(context);
 }