Exemple #1
0
        public async Task <bool> AddNoReturn(CompatibilityMinimal bllCompatibility)
        {
            if (bllCompatibility.Component1Id.Equals(bllCompatibility.Component2Id))
            {
                Console.WriteLine("Self-compatibility detected, skipping add");
                return(false);
            }

            var compatibilities = await ServiceRepository.AllAsyncMinimal();

            var compatibility = compatibilities.ToList().FirstOrDefault(c =>
                                                                        c.Component1Id.Equals(bllCompatibility.Component1Id) &&
                                                                        c.Component2Id.Equals(bllCompatibility.Component2Id) ||
                                                                        c.Component1Id.Equals(bllCompatibility.Component2Id) &&
                                                                        c.Component2Id.Equals(bllCompatibility.Component1Id));

            if (compatibility != null)
            {
                Console.WriteLine("Duplicate compatibility detected, skipping add");
                return(false);
            }

            ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllCompatibility));
            return(true);
        }
        public async Task <bool> AddNoReturn(ComponentInComputerMinimal bllComponentInComputer)
        {
            var componentsInComputers = await ServiceRepository.AllAsyncFull();

            var thisComputerComponents =
                componentsInComputers.Where(cic => cic.ComputerId == bllComponentInComputer.ComputerId).ToList();
            var toBeChecked = _compatibilityCheckList[bllComponentInComputer.ComponentTypeName];

            foreach (var typeName in toBeChecked)
            {
                var componentsWithType =
                    thisComputerComponents.Where(cic => cic.Component !.ComponentType !.ComponentTypeName == typeName).ToList();
                var isCompatible = true;
                foreach (var componentt in componentsWithType)
                {
                    isCompatible = await CheckCompatibility(bllComponentInComputer.ComponentId, componentt);

                    if (!isCompatible)
                    {
                        break;
                    }
                }


                if (!isCompatible)
                {
                    Console.WriteLine("Incompatible components");
                    return(false);
                }
            }

            var component = thisComputerComponents.FirstOrDefault(t =>
                                                                  t.Component !.ComponentTypeId.Equals(bllComponentInComputer.ComponentTypeId) &&
                                                                  t.Component.ComponentType !.ComponentTypeName != "Storage");

            if (component == null)
            {
                ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllComponentInComputer));
                return(true);
            }

            if (component != null)
            {
                Console.WriteLine("Duplicate non storage type on pc detected, skipping add");
            }

            return(false);
        }
 public void AddNoReturn(UnitOfMeasureMinimal bllUnitOfMeasure)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllUnitOfMeasure));
 }
Exemple #4
0
 public void AddNoReturn(ComponentTestMinimal bllComponentTest)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllComponentTest));
 }
Exemple #5
0
 public void AddNoReturn(SpecificationMinimal bllSpecification)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllSpecification));
 }
Exemple #6
0
 public void AddNoReturn(TestTypeMinimal bllTestType)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllTestType));
 }
 public void AddNoReturn(ComputerMinimal bllComputer)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllComputer));
 }
 public void AddNoReturn(ComponentTypeSpecificationMinimal bllComponentTypeSpecificationMinimalList)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllComponentTypeSpecificationMinimalList));
 }
 public void AddNoReturn(ManufacturerMinimal bllManufacturer)
 {
     ServiceRepository.AddNoReturn(_mapper.MapToDALMinimal(bllManufacturer));
 }