public async Task <IActionResult> Post([FromBody] OrganDto organDto) { var model = _mapper.Map <OrganDto, Organ>(organDto); await _organRepository.AddAsync(model); return(Ok(model)); }
public async Task <IActionResult> Put(int id, [FromBody] OrganDto organDto) { var actualData = await _organRepository.FindByIdAsync(id); if (actualData == null) { return(BadRequest(new ErrorResponseModel("Tipo de orgão não encontrado"))); } actualData = _mapper.Map <OrganDto, Organ>(organDto, actualData); await _organRepository.UpdateAsync(actualData); return(Ok(actualData)); }
/// <summary> /// 组装行政区划市区县数据 /// </summary> /// <param name="organinfo"></param> /// <param name="level"></param> /// <param name="code"></param> /// <param name="Areadata"></param> /// <param name="bmcode"></param> private void GetAreaData(ref OrganDto organinfo, int level, string code, ref string Areadata, string bmcode) { if (level == 4) { organinfo.所属居委会 = bmcode; } else if (level == 3) { organinfo.所属街道 = bmcode; } else if (level == 2) { organinfo.所属区县 = bmcode; } else if (level == 1) { organinfo.所属市 = bmcode; } else { organinfo.所属省 = bmcode; } Areadata = code; }
/// <summary> /// 根据机构id获取机构信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public OrganDto GetOrganDtoInfo(Organ orginfo, string pName) { OrganDto model = new OrganDto(); try { model.id = orginfo.id; model.级id = orginfo.级id; model.称 = orginfo.称; model.地址 = orginfo.地址; model.性质 = orginfo.性质; model.执业证代码 = orginfo.执业证代码; model.机构码 = orginfo.机构码; model.电话 = orginfo.电话; model.简码 = orginfo.简码; model.简称 = orginfo.简称; model.组织机构代码证 = orginfo.组织机构代码证; model.编码 = orginfo.编码; model.行政级别 = orginfo.行政级别; model.级机构名称 = pName; //机构行政区划信息 if (!string.IsNullOrEmpty(orginfo.所属行政区划)) { using (var db = new DbContext()) { //根据编码查询行政区划 var sqlStr = db.GetSql("CA00004-根据编码查询行政区划", null, null); ISqlBuilder sqlBuilder = db.Sql(sqlStr).Parameters("bianma", orginfo.所属行政区划); //执行SQL脚本 var item = sqlBuilder.GetModel <OrgArea>(); //组装行政区划市区县数据,判断性质 if (item != null && item.level > 0) { var Areadata = item.code; GetAreaData(ref model, item.level, item.code, ref Areadata, item.bmcode); //根据性质反向查询 for (int i = 1; i <= item.level; i++) { if (Areadata == null) { continue; } var dd = new OrgArea(); if (item.level - i >= 0) { sqlStr = db.GetSql("CA00004-根据编码查询行政区划", null, null); sqlBuilder = db.Sql(sqlStr).Parameters("bianma", Areadata); //执行SQL脚本 dd = sqlBuilder.GetModel <OrgArea>(); GetAreaData(ref model, dd.level, dd.code, ref Areadata, dd.bmcode); } } } } } } catch (Exception ex) { Logger.Instance.Error("根据机构id获取机构信息错误:!", ex); } return(model); }