Пример #1
0
        public int DumpBtsExcels(IEnumerable <BtsExcel> infos)
        {
            var containers = (from info in infos
                              join town in _townRepository.GetAllList()
                              on new { info.DistrictName, info.TownName } equals
                              new { town.DistrictName, town.TownName }
                              select new BtsExcelWithTownIdContainer
            {
                BtsExcel = info,
                TownId = town.Id
            }).ToArray();

            if (!containers.Any())
            {
                return(0);
            }
            var items =
                Mapper.Map <IEnumerable <BtsExcelWithTownIdContainer>, List <BtsWithTownIdContainer> >(containers);

            items.ForEach(x => { x.CdmaBts.TownId = x.TownId; });

            var count = 0;

            foreach (var bts in items.Select(x => x.CdmaBts).ToList())
            {
                if (_btsRepository.Insert(bts) != null)
                {
                    count++;
                }
            }
            _btsRepository.SaveChanges();
            return(count);
        }
Пример #2
0
        public CdmaBts UpdateTownInfo(int btsId, int townId)
        {
            var bts = _btsRepository.FirstOrDefault(x => x.BtsId == btsId);

            if (bts == null)
            {
                return(null);
            }
            bts.TownId = townId;
            _btsRepository.SaveChanges();
            return(bts);
        }