public int SaveENodebs(IEnumerable <CollegeENodebExcel> eNodebExcels, IENodebRepository eNodebRepository)
        {
            int count = 0;

            foreach (CollegeENodebExcel excel in eNodebExcels)
            {
                ENodeb eNodeb = eNodebRepository.GetAll().FirstOrDefault(x => x.ENodebId == excel.ENodebId);
                if (eNodeb == null)
                {
                    continue;
                }
                InfrastructureInfo infrastructure = _repository.InfrastructureInfos.FirstOrDefault(x =>
                                                                                                   x.HotspotName == excel.CollegeName && x.HotspotType == HotspotType.College &&
                                                                                                   x.InfrastructureType == InfrastructureType.ENodeb && x.InfrastructureId == eNodeb.Id);
                if (infrastructure == null)
                {
                    infrastructure = new InfrastructureInfo
                    {
                        HotspotName        = excel.CollegeName,
                        HotspotType        = HotspotType.College,
                        InfrastructureType = InfrastructureType.ENodeb,
                        InfrastructureId   = eNodeb.Id
                    };
                    _repository.AddOneInfrastructure(infrastructure);
                    _repository.SaveChanges();
                }
                count++;
            }
            return(count);
        }
Beispiel #2
0
        public async Task <int> SaveBuildingHotSpot(HotSpotView dto)
        {
            var info =
                _repository.FirstOrDefault(
                    x => x.HotspotName == dto.HotspotName && x.InfrastructureType == InfrastructureType.HotSpot);

            if (info == null)
            {
                info = dto.MapTo <InfrastructureInfo>();
                info.InfrastructureType = InfrastructureType.HotSpot;
                await _repository.InsertAsync(info);
            }
            else
            {
                dto.MapTo(info);
            }

            return(_repository.SaveChanges());
        }
        public int AddOneMonitor(int cellId, byte sectorId)
        {
            var cell = _cellRepository.GetBySectorId(cellId, sectorId);

            if (cell == null)
            {
                return(0);
            }
            var item = _repository.GetTopPreciseMonitor(cell.Id);

            if (item != null)
            {
                return(0);
            }
            _repository.Insert(new InfrastructureInfo
            {
                InfrastructureId = cell.Id,
                HotspotType      = HotspotType.TopPrecise
            });
            return(_repository.SaveChanges());
        }