/// <summary>
        /// 单一添加房子和居民关系
        /// </summary>
        /// <param name="inhabitantAndHouseInfoAddMiddle"></param>
        /// <returns></returns>
        public int AddHouseInfoRelationShipSingle(InhabitantAndHouseInfoAddMiddle inhabitantAndHouseInfoAddMiddle)
        {
            var aAddInsertModel = _IMapper.Map <InhabitantAndHouseInfoAddMiddle, InfoRelationShip>(inhabitantAndHouseInfoAddMiddle);

            _houseInfoRelationShipRepository.Add(aAddInsertModel);
            return(_houseInfoRelationShipRepository.SaveChanges());
        }
Пример #2
0
        /// <summary>
        /// 单一插入居民信息
        /// </summary>
        /// <param name="inhabitantAndHouseInfoAddMiddle"></param>
        /// <returns></returns>
        public int AddInhabitantSingle(InhabitantAndHouseInfoAddMiddle inhabitantAndHouseInfoAddMiddle)
        {
            var aAddInsertModel = _IMapper.Map <InhabitantAndHouseInfoAddMiddle, ResidentInfo>(inhabitantAndHouseInfoAddMiddle);

            aAddInsertModel.AddTime = DateTime.Now;
            _inhabitantRepository.Add(aAddInsertModel);
            return(_inhabitantRepository.SaveChanges());
        }
Пример #3
0
        public IQueryable <HouseInfo> HouseInfoSerachByWhere2(InhabitantAndHouseInfoAddMiddle inhabitantAndHouseInfoAddMiddle)
        {
            //查询条件
            var predicate = SearchHouseInfoWhere2(inhabitantAndHouseInfoAddMiddle);
            var result    = DbSet
                            .Where(predicate);

            return(result);
        }
Пример #4
0
        private Expression <Func <HouseInfo, bool> > SearchHouseInfoWhere2(InhabitantAndHouseInfoAddMiddle inhabitantAndHouseInfoAddMiddle)
        {
            var predicate = WhereExtension.True <HouseInfo>();//初始化where表达式


            predicate = predicate.And(p => p.Area == inhabitantAndHouseInfoAddMiddle.Area);
            predicate = predicate.And(p => p.UnitNo == inhabitantAndHouseInfoAddMiddle.UnitNo);
            predicate = predicate.And(p => p.BuildingNo == inhabitantAndHouseInfoAddMiddle.BuildingNo);
            predicate = predicate.And(p => p.HouseNo == inhabitantAndHouseInfoAddMiddle.HouseNo);
            //predicate = predicate.And(p => p.Status == "1");

            return(predicate);
        }
Пример #5
0
        /// <summary>
        /// 单一添加房子信息
        /// </summary>
        /// <param name="inhabitantAndHouseInfoAddMiddle"></param>
        /// <returns></returns>
        public int AddHouseInfoSingle(InhabitantAndHouseInfoAddMiddle inhabitantAndHouseInfoAddMiddle)
        {
            var aAddInsertModel = _IMapper.Map <InhabitantAndHouseInfoAddMiddle, HouseInfo>(inhabitantAndHouseInfoAddMiddle);
            var SearchResult    = _houseInfoRepository.HouseInfoSerachByWhere2(inhabitantAndHouseInfoAddMiddle).ToList();

            if (SearchResult.Count > 0)
            {
                return(0);
            }
            else
            {
                _houseInfoRepository.Add(aAddInsertModel);
                return(_houseInfoRepository.SaveChanges());
            }
        }
Пример #6
0
        ///// <summary>
        ///// 批量更新
        ///// </summary>
        ///// <param name="inhabitantUpdateViewModel"></param>
        ///// <returns></returns>
        //public int Inhabitant_Update(InhabitantUpdateViewModel inhabitantUpdateViewModel)
        //{
        //    var tempUpdateViewMiddle = inhabitantUpdateViewModel.inhabitantUpdateViewModel;
        //    var InhabitantUpdateModel = _IMapper.Map<List<InhabitantUpdateMiddle>, List<ResidentInfo>>(tempUpdateViewMiddle);
        //  //  var InfoRelationShip = _IMapper.Map<List<InhabitantUpdateMiddle>, List<InfoRelationShip>>(tempUpdateViewMiddle);

        //    //int InhabitantAndHouseInfo_add_Count = 0;
        //    //foreach (InhabitantUpdateMiddle model in inhabitantUpdateViewModel.inhabitantUpdateViewModel)
        //    //{
        //    //    //验证居民是否重复
        //    //    var checkInhabitant = Inhabitant_ByIdNo_Search(model.IdNumber);
        //    //    if (checkInhabitant != null)
        //    //    {
        //    //        //  var tempUpdateViewMiddle = inhabitantUpdateViewModel.inhabitantUpdateViewModel;
        //    //        var  InhabitantUpdateModel = _IMapper.Map<InhabitantUpdateMiddle, ResidentInfo>(model);
        //    for (int i = 0; i < tempUpdateViewMiddle.Count; i++)
        //    {
        //          var InfoRelationShip = _houseInfoRelationShipRepository.InfoRelationShipSerachByIdNoWhere(tempUpdateViewMiddle[i].Id.ToString());
        //                for (int j = 0; j < InfoRelationShip.Count; j++)
        //                {
        //                    InfoRelationShip[j].RelationWithHousehold = tempUpdateViewMiddle[i].RelationWithHousehold;
        //                    _houseInfoRelationShipRepository.Update(InfoRelationShip[j]);
        //                }
        //         //   }
        //            _houseInfoRelationShipRepository.SaveChanges();
        //            _inhabitantRepository.UpdateInfo(InhabitantUpdateModel);
        //            //InhabitantAndHouseInfo_add_Count++;

        //        //else
        //        //{
        //        //    InhabitantAndHouseInfoAddMiddle ia = new InhabitantAndHouseInfoAddMiddle();

        //        //    var aAddInsertModel = _IMapper.Map<InhabitantUpdateMiddle, InhabitantAndHouseInfoAddMiddle>(model);
        //        //    //  var infos= _inhabitantRepository.GetById(model.HouseHolderId.Value);

        //        //    var infos = _houseInfoRelationShipRepository.InfoRelationShipSerachByIdNoWhere(model.HouseHolderId.Value.ToString());
        //        //    aAddInsertModel.HouseId = infos[0].HouseInfoId;
        //        //    aAddInsertModel.RelationShipId = Guid.NewGuid();
        //        //    aAddInsertModel.InhabitantId = Guid.NewGuid();
        //        //    //添加居民信息
        //        //    AddInhabitantSingle(aAddInsertModel);

        //        //    //添加居民和房子关系
        //        //    AddHouseInfoRelationShipSingle(aAddInsertModel);
        //        //    InhabitantAndHouseInfo_add_Count++;
        //        //    //添加党员信息
        //        //    if (aAddInsertModel.Politics == "中共党员")
        //        //    {
        //        //        PartyInfoAddViewModel partyInfoAddViewModel = new PartyInfoAddViewModel();
        //        //        partyInfoAddViewModel.ResidentId = aAddInsertModel.InhabitantId;
        //        //        partyInfoAddViewModel.IdNumber = aAddInsertModel.IdNumber;

        //        //        int Party_add_Count = 0;
        //        //        Party_add_Count = AddPartyInfo(partyInfoAddViewModel);
        //        //    }

        //        //}


        //    }


        //    return _inhabitantRepository.SaveChanges();
        //}



        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="inhabitantUpdateViewModel"></param>
        /// <returns></returns>
        public int Inhabitant_Update(InhabitantUpdateViewModel inhabitantUpdateViewModel)
        {
            int InhabitantAndHouseInfo_add_Count = 0;

            foreach (InhabitantUpdateMiddle model in inhabitantUpdateViewModel.inhabitantUpdateViewModel)
            {
                if (model.Id != null)//说明是修改
                {
                    var residentInfo = _inhabitantRepository.GetById(model.Id.Value);
                    var houseInfo    = _houseInfoRepository.GetByHouseHolderIdNo(residentInfo.IdNumber);

                    residentInfo = _IMapper.Map <InhabitantUpdateMiddle, ResidentInfo>(model, residentInfo);//修改居民信息
                    _inhabitantRepository.Update(residentInfo);
                    _inhabitantRepository.SaveChanges();

                    if (houseInfo.Count > 0)//说明是房主
                    {
                        var result = _IMapper.Map <ResidentInfo, ResidentInfoMiddleId>(residentInfo);
                        houseInfo[0] = _IMapper.Map <ResidentInfoMiddleId, HouseInfo>(result, houseInfo[0]);//修改房屋信息

                        var SearchResult = _houseInfoRepository.HouseInfoSerachByWhere3(model).ToList();
                        if (SearchResult.Count > 0 && houseInfo[0].Id != SearchResult[0].Id)
                        {
                            return(999999);
                        }

                        houseInfo[0].Area       = model.Area;       // 小区名称
                        houseInfo[0].BuildingNo = model.BuildingNo; // 楼号
                        houseInfo[0].UnitNo     = model.UnitNo;     // 单元号
                        houseInfo[0].HouseNo    = model.HouseNo;    // 门牌号

                        _houseInfoRepository.Update(houseInfo[0]);
                        _houseInfoRepository.SaveChanges();
                    }

                    var InfoRelationShip = _houseInfoRelationShipRepository.InfoRelationShipSerachByIdNoWhere(residentInfo.Id.ToString());
                    for (int j = 0; j < InfoRelationShip.Count; j++)
                    {
                        InfoRelationShip[j].RelationWithHousehold = model.RelationWithHousehold;
                        _houseInfoRelationShipRepository.Update(InfoRelationShip[j]);
                    }
                    _houseInfoRelationShipRepository.SaveChanges();

                    InhabitantAndHouseInfo_add_Count++;
                }
                else//说明是新增
                {
                    InhabitantAndHouseInfoAddMiddle ia = new InhabitantAndHouseInfoAddMiddle();
                    var aAddInsertModel = _IMapper.Map <InhabitantUpdateMiddle, InhabitantAndHouseInfoAddMiddle>(model);
                    var infos           = _houseInfoRelationShipRepository.InfoRelationShipSerachByIdNoWhere(model.HouseHolderId.Value.ToString());

                    //var infos =_houseInfoRepository.GetByHouseHolderIdNo(model.HouseHolderId.Value.ToString());
                    aAddInsertModel.HouseId        = infos[0].HouseInfoId;
                    aAddInsertModel.RelationShipId = Guid.NewGuid();
                    aAddInsertModel.InhabitantId   = Guid.NewGuid();
                    //添加居民信息
                    AddInhabitantSingle(aAddInsertModel);

                    //添加居民和房子关系
                    AddHouseInfoRelationShipSingle(aAddInsertModel);
                    InhabitantAndHouseInfo_add_Count++;
                    //添加党员信息
                    if (aAddInsertModel.Politics == "中共党员")
                    {
                        PartyInfoAddViewModel partyInfoAddViewModel = new PartyInfoAddViewModel();
                        partyInfoAddViewModel.ResidentId = aAddInsertModel.InhabitantId;
                        partyInfoAddViewModel.IdNumber   = aAddInsertModel.IdNumber;

                        int Party_add_Count = 0;
                        Party_add_Count = AddPartyInfo(partyInfoAddViewModel);
                    }
                }
            }


            return(InhabitantAndHouseInfo_add_Count);
        }