public void TestCustomBatchPropValues()
        {
            // Prerequisite entities
            Plastic         pp   = PlasticsRepository.CreatePlastic("PP", "Polypropylene");
            Material        mat  = MaterialsRepository.CreateMaterial("mat", "manu", "manu-id", pp);
            StorageSite     site = LocationsRepository.CreateStorageSite("test_site");
            StorageArea     area = LocationsRepository.CreateStorageArea(site, "test_area");
            StorageLocation loc  = new StorageLocation()
            {
                StorageSiteId   = site.Id,
                StorageAreaId   = area.Id,
                StorageSiteName = site.Name,
                StorageAreaName = area.Name
            };
            CustomBatchProp prop1 = PropRepository.CreateCustomBatchProp("prop-1");
            CustomBatchProp prop2 = PropRepository.CreateCustomBatchProp("prop-2");

            // Create batch with custom prop values
            MaterialBatch batch = Repository.CreateMaterialBatch(mat, DateTime.Today.AddDays(17), loc, 42, 42, new Dictionary <Guid, string>()
            {
                { prop1.Id, "Ak Bars" },
                { prop2.Id, "Aloha" }
            }, false);

            Assert.Equal(2, batch.CustomProps.Count);

            // Test updating
            batch.CustomProps[prop1.Id] = "UPDATE TEST";
            Repository.UpdateMaterialBatch(batch);
            batch = Repository.GetMaterialBatch(batch.Id);
            Assert.Equal(2, batch.CustomProps.Count);
            Assert.Single(batch.CustomProps.Where(p => p.Value == "UPDATE TEST"));
        }
 public LmPlatformRepositoriesContainer()
 {
     UsersRepository                   = new UsersRepository(_dataContext);
     BugsRepository                    = new BugsRepository(_dataContext);
     BugLogsRepository                 = new BugLogsRepository(_dataContext);
     GroupsRepository                  = new GroupsRepository(_dataContext);
     ProjectsRepository                = new ProjectsRepository(_dataContext);
     ProjectUsersRepository            = new ProjectUsersRepository(_dataContext);
     ProjectCommentsRepository         = new ProjectCommentsRepository(_dataContext);
     StudentsRepository                = new StudentsRepository(_dataContext);
     SubjectRepository                 = new SubjectRepository(_dataContext);
     TestsRepository                   = new TestsRepository(_dataContext);
     TestUnlocksRepository             = new TestUnlockRepository(_dataContext);
     QuestionsRepository               = new QuestionsRepository(_dataContext);
     UsersRepository                   = new UsersRepository(_dataContext);
     ModulesRepository                 = new ModulesRepository(_dataContext);
     LecturerRepository                = new LecturerRepository(_dataContext);
     MessageRepository                 = new MessageRepository(_dataContext);
     MaterialsRepository               = new MaterialsRepository(_dataContext);
     FoldersRepository                 = new FoldersRepository(_dataContext);
     SubGroupRepository                = new SubGroupRepository(_dataContext);
     AttachmentRepository              = new AttachmentRepository(_dataContext);
     LecturesRepository                = new LecturesRepository(_dataContext);
     LabsRepository                    = new LabsRepository(_dataContext);
     ProjectUsersRepository            = new ProjectUsersRepository(_dataContext);
     PracticalRepository               = new PracticalRepository(_dataContext);
     ConceptRepository                 = new ConceptRepository(_dataContext);
     WatchingTimeRepository            = new WatchingTimeRepository(_dataContext);
     TestQuestionPassResultsRepository = new TestQuestionPassResultsRepository(_dataContext);
     //todo UNUSED ProjectMatrixRequirementsRepository = new ProjectMatrixRequirementsRepository(_dataContext);
 }
Example #3
0
        public static MaterialsRepository GetMaterialsRepository()
        {
            var repository = new MaterialsRepository();

            repository.UnitOfWork = GetUnitOfWork();
            return(repository);
        }
Example #4
0
        public static MaterialsRepository GetMaterialsRepository(IUnitOfWork unitOfWork)
        {
            var repository = new MaterialsRepository();

            repository.UnitOfWork = unitOfWork;
            return(repository);
        }
Example #5
0
 public void Activate()
 {
     _profileRepository         = new ProfileRepository();
     _materialsRepository       = new MaterialsRepository();
     _servicesRepository        = new ServicesRepository();
     _serviceMaterialRepository = new ServiceMaterialsRepository();
     _quotesRepository          = new QuotesRepository();
     _customersRepository       = new CustomersRepository();
 }
Example #6
0
 public void Activate()
 {
     _profileRepository = new ProfileRepository();
     _materialsRepository = new MaterialsRepository();
     _servicesRepository = new ServicesRepository();
     _serviceMaterialRepository = new ServiceMaterialsRepository();
     _quotesRepository = new QuotesRepository();
     _customersRepository = new CustomersRepository();
 }
        /// <summary>
        /// Updates an existing material's master data.
        /// </summary>
        /// <param name="id">ID of the material to update.</param>
        /// <param name="name">The material's name.</param>
        /// <param name="manufacturerName">Name of the manufacturer.</param>
        /// <param name="manufacturerSpecificId">The manufacturer's ID for this material.</param>
        /// <param name="plastic">Type of the material.</param>
        /// <returns>Retursn the updated material.</returns>
        /// <exception cref="MaterialNotFoundException">Thrown if no matching material could be found.</exception>
        public Material UpdateMaterial(int id, string name, string manufacturerName, string manufacturerSpecificId, Plastic plastic)
        {
            Material material = GetMaterialOrThrowNotFoundException(id);

            material.Name                   = name;
            material.Manufacturer           = manufacturerName;
            material.ManufacturerSpecificId = manufacturerSpecificId;
            material.Type                   = plastic;
            MaterialsRepository.UpdateMaterial(material);
            return(material);
        }
Example #8
0
 public void Awake()
 {
     if (instance == null)
     {
         instance     = this;
         achievements = new List <Achievement> ();
         ballMaterial = MaterialsRepository.Get("green");
         SkinsRepository.addSkin(new Skin(SpriteRepository.Get("green"), ballMaterial));
         addAchievements();
         DontDestroyOnLoad(this.gameObject);
     }
 }
Example #9
0
 public ICollection <Material> GetMaterialsFromSubject(string subjectName)
 {
     try
     {
         var subject = SubjectsRepository.GetList().Where(x => x.Name == subjectName).First();
         return(MaterialsRepository.GetList(subject));
     }
     catch (Exception)
     {
         return(new List <Material>());
     }
 }
Example #10
0
        /// <summary>
        /// Attempts to get a material from the underlying repository and throws a <see cref="MaterialNotFoundException"/> if no matching material could be found.
        /// </summary>
        /// <param name="id">ID of the material to get.</param>
        /// <exception cref="MaterialNotFoundException">Thrown if no matching material could be found.</exception>
        /// <returns>Returns the material, if found.</returns>
        private Material GetMaterialOrThrowNotFoundException(int id)
        {
            Material material = MaterialsRepository.GetMaterial(id);

            // Check for material existence
            if (material == null)
            {
                throw new MaterialNotFoundException(id);
            }

            return(material);
        }
Example #11
0
 private void treeViewNotes_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Node.Tag is Material)
     {
         try
         {
             richTextBoxNote.Text = MaterialsRepository.GetDetailsByID((e.Node.Tag as Material).Id).Content;
         }
         catch (Exception)
         {
             MessageBox.Show(Properties.Resources.ConnectionProblem);
         }
     }
 }
        public Materials_Repository()
        {
            log4net.Config.XmlConfigurator.Configure();
            m_NHConfiguration = new ConfigurationBuilder().Build();
            m_SessionFactory = m_NHConfiguration.BuildSessionFactory();
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
            m_Repository = new MaterialsRepository(m_SessionFactory);

            //setup test data ...
            using (ISession session = m_SessionFactory.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    //clean any existing records
                    foreach (Material m in session.Query<Material>())
                    {
                        session.Delete(m);
                    }
                    transaction.Commit();
                }
                using (ITransaction transaction = session.BeginTransaction())
                {
                    //insert some test data
                    for (int i = 0; i < 10; i++)
                    {
                        Material material = new Material();
                        material.PartNumber = "Part" + i.ToString();
                        material.Description = "This is part " + i.ToString();
                        material.Type = MaterialType.Component;
                        material.PiecesPerCase = 5;
                        material.EachesPerPiece = 5;

                        session.Save(material);
                    }
                    transaction.Commit();
                }
            }
        }
Example #13
0
 /// <summary>
 /// Gets and filters materials.
 /// </summary>
 /// <param name="partialName">A string to filter material names with.</param>
 /// <param name="partialManufacturerName">A string to filter manufacturers with.</param>
 /// <param name="plastic">Type of the material to filter with.</param>
 /// <returns>Returns a filtered list of materials</returns>
 public IEnumerable <Material> GetMaterials(string partialName, string partialManufacturerName, Plastic plastic)
 {
     return(MaterialsRepository.GetFilteredMaterials(partialName, partialManufacturerName, plastic));
 }
Example #14
0
 /// <summary>
 /// Gets all available materials.
 /// </summary>
 /// <returns>Reutrns all materials.</returns>
 public IEnumerable <Material> GetAllMaterials()
 {
     return(MaterialsRepository.GetAllMaterials());
 }
        public void TestMaterialBatchRepository()
        {
            Assert.Empty(Repository.GetAllMaterialBatches());

            // Create prerequisite entities
            Plastic         pp   = PlasticsRepository.CreatePlastic("PP", "Polypropylene");
            Plastic         ep   = PlasticsRepository.CreatePlastic("EP", "Epoxy");
            Material        pp1  = MaterialsRepository.CreateMaterial("pp-1", "Umbrella Corp.", "pp-1", pp);
            Material        ep1  = MaterialsRepository.CreateMaterial("ep-1", "Umbrella Corp.", "ep-1", ep);
            StorageSite     site = LocationsRepository.CreateStorageSite("Test Site");
            StorageArea     area = LocationsRepository.CreateStorageArea(site, "Test Area");
            StorageLocation loc  = new StorageLocation()
            {
                StorageSiteId   = site.Id,
                StorageAreaId   = area.Id,
                StorageSiteName = site.Name,
                StorageAreaName = area.Name
            };

            // Create batch and check return
            DateTime      expDate = DateTime.Today.AddDays(5);
            MaterialBatch batch   = Repository.CreateMaterialBatch(pp1, expDate, loc, 1, 125.0, new Dictionary <Guid, string>(), false);

            Assert.Equal(pp1.Id, batch.Material.Id);
            Assert.Equal(expDate, batch.ExpirationDate);
            Assert.Equal(area.Id, batch.StorageLocation.StorageAreaId);
            Assert.Equal(site.Id, batch.StorageLocation.StorageSiteId);
            Assert.Equal(1, batch.BatchNumber);
            Assert.Equal(125.0, batch.Quantity);
            Assert.Empty(batch.CustomProps);
            Assert.False(batch.IsLocked);
            Assert.False(batch.IsArchived);

            // Check get all batches
            IEnumerable <MaterialBatch> batches = Repository.GetAllMaterialBatches();

            Assert.Single(batches);
            batch = batches.Single();
            Assert.Equal(pp1.Id, batch.Material.Id);
            Assert.Equal(expDate, batch.ExpirationDate);
            Assert.Equal(area.Id, batch.StorageLocation.StorageAreaId);
            Assert.Equal(site.Id, batch.StorageLocation.StorageSiteId);
            Assert.Equal(1, batch.BatchNumber);
            Assert.Equal(125.0, batch.Quantity);
            Assert.Empty(batch.CustomProps);
            Assert.False(batch.IsLocked);
            Assert.False(batch.IsArchived);

            // Check get single batch
            batch = Repository.GetMaterialBatch(batch.Id);
            Assert.Equal(pp1.Id, batch.Material.Id);
            Assert.Equal(expDate, batch.ExpirationDate);
            Assert.Equal(area.Id, batch.StorageLocation.StorageAreaId);
            Assert.Equal(site.Id, batch.StorageLocation.StorageSiteId);
            Assert.Equal(1, batch.BatchNumber);
            Assert.Equal(125.0, batch.Quantity);
            Assert.Empty(batch.CustomProps);
            Assert.False(batch.IsLocked);
            Assert.False(batch.IsArchived);

            // Check filters
            batches = Repository.GetMaterialBatches(pp1.Id);
            Assert.Single(batches);
            batch = batches.Single();
            Assert.Equal(pp1.Id, batch.Material.Id);
            batches = Repository.GetMaterialBatches(siteId: site.Id);
            Assert.Single(batches);
            batch = batches.Single();
            Assert.Equal(pp1.Id, batch.Material.Id);
            batches = Repository.GetMaterialBatches(pp1.Id, site.Id);
            Assert.Single(batches);
            batch = batches.Single();
            Assert.Equal(pp1.Id, batch.Material.Id);
            batches = Repository.GetMaterialBatches(99999, site.Id);
            Assert.Empty(batches);
            batches = Repository.GetMaterialBatches(pp1.Id, area.Id);
            Assert.Empty(batches);

            // Create another batch and test filters again
            Repository.CreateMaterialBatch(ep1, expDate, loc, 33, 25.5, new Dictionary <Guid, string>(), false);
            batches = Repository.GetMaterialBatches(ep1.Id, site.Id);
            Assert.Single(batches);
            batch = batches.Single();
            Assert.Equal(ep1.Id, batch.Material.Id);
            batches = Repository.GetMaterialBatches(siteId: site.Id);
            Assert.Equal(2, batches.Count());
            Assert.Single(batches, b => b.Material.Id == pp1.Id);
            Assert.Single(batches, b => b.Material.Id == ep1.Id);

            // Test updating a batch
            batch = batches.Single(b => b.Material.Id == ep1.Id);
            Assert.Equal(33, batch.BatchNumber);
            Assert.Equal(25.5, batch.Quantity);
            Assert.False(batch.IsLocked);
            batch.BatchNumber = 333;
            batch.Quantity    = 203.1;
            batch.IsLocked    = true;
            Repository.UpdateMaterialBatch(batch);
            batch = Repository.GetMaterialBatch(batch.Id);
            Assert.Equal(333, batch.BatchNumber);
            Assert.Equal(203.1, batch.Quantity);
            Assert.True(batch.IsLocked);

            // Test archiving
            Guid archivedId = batch.Id;

            batch.IsArchived = true;
            Repository.UpdateMaterialBatch(batch);
            batches = Repository.GetAllMaterialBatches();
            Assert.Single(batches);
            batch = batches.Single();
            Assert.Equal(pp1.Id, batch.Material.Id);

            // Still directly gettable by ID
            batch = Repository.GetMaterialBatch(archivedId);
            Assert.Equal(ep1.Id, batch.Material.Id);
        }
Example #16
0
 /// <summary>
 /// Creates a new material.
 /// </summary>
 /// <param name="name">The new material's name.</param>
 /// <param name="manufacturerName">Name of the manufacturer.</param>
 /// <param name="manufacturerSpecificId">The manufacturer's ID for this material.</param>
 /// <param name="plastic">Type of the material.</param>
 /// <returns>Retursn the newly created material.</returns>
 public Material CreateMaterial(string name, string manufacturerName, string manufacturerSpecificId, Plastic plastic)
 {
     return(MaterialsRepository.CreateMaterial(name, manufacturerName, manufacturerSpecificId, plastic));
 }
Example #17
0
 public override void effect()
 {
     SkinsRepository.addSkin(new Skin(achieved, MaterialsRepository.Get("orange")));
 }
Example #18
0
        public void TestTransactionRepository()
        {
            // Create prerequisite entities
            Plastic         plastic  = PlasticsRepository.CreatePlastic("PP", "Polypropylene");
            Material        material = MaterialsRepository.CreateMaterial("m", "m", "m", plastic);
            StorageSite     site     = LocationsRepository.CreateStorageSite("site");
            StorageArea     area     = LocationsRepository.CreateStorageArea(site, "area");
            StorageLocation location = new StorageLocation()
            {
                StorageSiteId   = site.Id,
                StorageAreaId   = area.Id,
                StorageSiteName = site.Name,
                StorageAreaName = area.Name
            };
            MaterialBatch batch = BatchRepository.CreateMaterialBatch(material, DateTime.Today.AddDays(3), location, 42, 42, new Dictionary <Guid, string>(), false);

            (string password, byte[] salt) = new PasswordHashingService(new LoggerFactory()).HashAndSaltPassword("test");
            User user = UserRepository.CreateUser("alex", "Alex", password, salt, Role.Administrator);

            // Create transactions
            Repository.LogTransaction(new Transaction()
            {
                Id = Guid.NewGuid(),
                MaterialBatchId = batch.Id,
                Quantity        = -3,
                Timestamp       = DateTime.Today.AddDays(-3),
                UserId          = user.Id
            });
            Repository.LogTransaction(new Transaction()
            {
                Id = Guid.NewGuid(),
                MaterialBatchId = batch.Id,
                Quantity        = -2,
                Timestamp       = DateTime.Today.AddDays(-2),
                UserId          = user.Id
            });
            Guid lastId = Guid.NewGuid();

            Repository.LogTransaction(new Transaction()
            {
                Id = lastId,
                MaterialBatchId = batch.Id,
                Quantity        = -1,
                Timestamp       = DateTime.Today.AddDays(-1),
                UserId          = user.Id
            });

            // Check with getAll
            IEnumerable <Transaction> transactions = Repository.GetTransactionsForBatch(batch.Id);

            Assert.Equal(3, transactions.Count());
            Assert.Single(transactions, t => t.Quantity == -3);
            Assert.Single(transactions, t => t.Quantity == -2);
            Assert.Single(transactions, t => t.Quantity == -1);

            // Check get last
            Transaction transaction = Repository.GetLastTransactionForBatch(batch.Id);

            Assert.Equal(batch.Id, transaction.MaterialBatchId);
            Assert.Equal(lastId, transaction.Id);
            Assert.Equal(-1, transaction.Quantity);

            // Test transaction update
            transaction.Quantity = 200;
            Repository.UpdateTransaction(transaction);
            transaction = Repository.GetLastTransactionForBatch(batch.Id);
            Assert.Equal(lastId, transaction.Id);
            Assert.Equal(200, transaction.Quantity);
        }
Example #19
0
 public override void effect()
 {
     SkinsRepository.addSkin(new Skin(achieved, MaterialsRepository.Get("eight_ball")));
 }