コード例 #1
0
        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);
        }
コード例 #2
0
 public ComponentInComputer MapToDomain(ComponentInComputerMinimal dalComponentInComputerMinimal)
 {
     return(Map <ComponentInComputerMinimal, ComponentInComputer>(dalComponentInComputerMinimal));
 }
コード例 #3
0
 public void RemoveNoReturnAsync(ComponentInComputerMinimal dalComponentInComputerMinimal)
 {
     RepoDbSet.Remove(_mapper.MapToDomain(dalComponentInComputerMinimal));
 }
コード例 #4
0
 public void AddNoReturn(ComponentInComputerMinimal dalComponentInComputerMinimal)
 {
     RepoDbSet.Add(_mapper.MapToDomain(dalComponentInComputerMinimal));
 }
コード例 #5
0
 public void RemoveNoReturnAsync(ComponentInComputerMinimal bllComponentInComputer)
 {
     ServiceRepository.RemoveNoReturnAsync(_mapper.MapToDALMinimal(bllComponentInComputer));
 }