public ActionResult <InhabitantAddResViewModel> Manage_OpinionInfo_Add(InhabitantAddViewModel inhabitantAddViewModel) { int Inhabitant_add_Count; //添加人员信息 Inhabitant_add_Count = _inhabitantService.AddInhabitant(inhabitantAddViewModel); var opinionInfoAddResModel = _inhabitantFactory.GetInhabitantAddResViewModel(); if (Inhabitant_add_Count > 0) { opinionInfoAddResModel.baseViewModel.IsSuccess = true; opinionInfoAddResModel.AddCount = Inhabitant_add_Count; opinionInfoAddResModel.baseViewModel.Message = "添加成功"; opinionInfoAddResModel.baseViewModel.ResponseCode = 200; _ILogger.Information("增添居民信息成功"); return(Ok(opinionInfoAddResModel)); } else { opinionInfoAddResModel.baseViewModel.IsSuccess = false; opinionInfoAddResModel.AddCount = 0; opinionInfoAddResModel.baseViewModel.Message = "添加失败"; opinionInfoAddResModel.baseViewModel.ResponseCode = 400; _ILogger.Information("增添居民信息失败"); return(BadRequest(opinionInfoAddResModel)); } }
/// <summary> /// 批量添加 /// </summary> /// <param name="inhabitantAddViewModel"></param> /// <returns></returns> public int AddInhabitant(InhabitantAddViewModel inhabitantAddViewModel) { var tempAddViewMiddle = inhabitantAddViewModel.inhabitantAddViewModel; var aAddInsertModel = _IMapper.Map <List <InhabitantAddMiddle>, List <ResidentInfo> >(tempAddViewMiddle); _inhabitantRepository.AddInfo(aAddInsertModel); return(_inhabitantRepository.SaveChanges()); }