/// <summary> /// 新增、修改学年表 /// </summary> /// <param name="model"></param> /// <returns></returns> public BaseResultModel <AcademicYearOutputModel> ModifyAcademicYear(AcademicYearInputModel model) { SuccessResultModel <AcademicYearOutputModel> result = new SuccessResultModel <AcademicYearOutputModel>(); ErrorResultModel <AcademicYearOutputModel> error = new ErrorResultModel <AcademicYearOutputModel>(); try { if (model.AcademicYearID.IsNullOrEmpty()) { result.Data = this.AcademicYearRepository.InsertAndReturn(model); } else { result.Data = this.AcademicYearRepository.UpdateWithKeysAndReturn(model); } return(result); } catch (Exception ex) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ModifyAcademicYear", JsonConvert.SerializeObject(model), "AcademicYear", "新增、修改学年表异常!", ex); error.ErrorCode = EnumErrorCode.系统异常; error.ErrorMessage = "新增、修改学年表异常!"; return(error); } }
/// <summary> /// 删除学年表 (逻辑删除) /// </summary> /// <param name="IDs"></param> /// <returns></returns> public BaseResultModel <int> DeleteAcademicYear(List <Guid?> IDs) { SuccessResultModel <int> result = new SuccessResultModel <int>(); ErrorResultModel <int> error = new ErrorResultModel <int>(); try { List <AcademicYearInputModel> delList = new List <AcademicYearInputModel>(); foreach (Guid?item in IDs) { delList.Add(new AcademicYearInputModel() { AcademicYearID = item, IsDelete = true }); } result.Data = this.AcademicYearRepository.UpdateWithKeys(delList.ToArray()); if (result.Data == 0) { error.ErrorCode = EnumErrorCode.业务执行失败; error.ErrorMessage = "请确认需要删除的数据!"; return(error); } return(result); } catch (Exception ex) { LogWriter.WriteLog(EnumLogLevel.Fatal, "DeleteAcademicYear", JsonConvert.SerializeObject(IDs), "AcademicYear", "删除学年表 (逻辑删除)异常!", ex); error.ErrorCode = EnumErrorCode.系统异常; error.ErrorMessage = "删除学年表 (逻辑删除)异常!"; return(error); } }
/// <summary> /// 新增、修改模块表 /// </summary> /// <param name="model"></param> /// <returns></returns> public BaseResultModel <ModelOutputModel> ModifyModel(ModelInputModel model) { SuccessResultModel <ModelOutputModel> result = new SuccessResultModel <ModelOutputModel>(); try { ModelOutputModel selModel = this.ModelRepository.SelectWithModel(new ModelModel() { ModelName = model.ModelName }); ModelOutputModel selModelCode = this.ModelRepository.SelectWithModel(new ModelModel() { ModelCode = model.ModelCode }); if (model.ModelID.IsNullOrEmpty()) { if (selModel != null) { return(new ErrorResultModel <ModelOutputModel>(EnumErrorCode.参数校验未通过, "名称已存在")); } if (selModelCode != null) { return(new ErrorResultModel <ModelOutputModel>(EnumErrorCode.参数校验未通过, "编号已存在")); } model.ModelID = model.ModelID ?? Guid.NewGuid(); List <ModelDetailInputModel> initModelDeatil = GetInitModelDetailList(model); TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { // 初始化表-- 》 全局固定字段: 工号、审核状态、审核时间、确认标识、确认人、确认时间 this.ModelDetailRepository.InsertCol(initModelDeatil.ToArray()); this.ModelDetailRepository.InitDBTable(model); result.Data = this.ModelRepository.InsertAndReturn(model); scope.Complete(); } } else { if (selModel != null && selModel.ModelID != model.ModelID) { return(new ErrorResultModel <ModelOutputModel>(EnumErrorCode.参数校验未通过, "名称已存在")); } if (selModelCode != null && selModelCode.ModelID != model.ModelID) { return(new ErrorResultModel <ModelOutputModel>(EnumErrorCode.参数校验未通过, "编号已存在")); } result.Data = this.ModelRepository.UpdateWithKeysAndReturn(model); } return(result); } catch (Exception ex) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ModifyModel", JsonConvert.SerializeObject(model), "Model", "新增、修改模块表异常!", ex); return(new ErrorResultModel <ModelOutputModel>(EnumErrorCode.系统异常, "新增、修改模块表异常")); } }
public async Task <ActionResult> Get([FromQuery] CarteiraMotoristaModel model) { var pontos = await _DetranVerificadorPontosCarteiraService.ConsultarPontos(_Mapper.Map <CarteiraMotorista>(model)); var result = new SuccessResultModel <PontosCarteiraTotalModel>(_Mapper.Map <PontosCarteiraTotalModel>(pontos)); return(Ok(result)); }
public async Task <ActionResult> Get([FromQuery] CarteiraModel model) { var pontos = await _DetranVerificadorPontosServices.ConsultarPontos(_Mapper.Map <Carteira>(model)); var result = new SuccessResultModel <IEnumerable <PontosCarteiraModel> >(_Mapper.Map <IEnumerable <PontosCarteiraModel> >(pontos)); return(Ok(result)); }
public async Task <ActionResult> Get([FromQuery] string numero) { var carteira = await _DetranConsultaCarteiraServices.ConsultarCarteira(numero); var result = new SuccessResultModel <Carteira>(_Mapper.Map <Carteira>(carteira)); return(Ok(result)); }
public async Task <ActionResult> Get([FromQuery] VeiculoModel model) { var debitos = await _DetranVerificadorDebitosServices.ConsultarDebitos(_Mapper.Map <Veiculo>(model)); var result = new SuccessResultModel <IEnumerable <DebitoVeiculoModel> >(_Mapper.Map <IEnumerable <DebitoVeiculoModel> >(debitos)); return(Ok(result)); }
public async Task <ActionResult> Get([FromQuery] UsuarioModel model) { var debitos = await _YoutubeGetRecomendadosServices.GetRecomendados(_Mapper.Map <Usuario>(model)); var result = new SuccessResultModel <VideosUsuarioModel>(_Mapper.Map <VideosUsuarioModel>(debitos)); return(Ok(result)); }
/// <summary> /// 删除模块表 (逻辑删除) /// </summary> /// <param name="IDs"></param> /// <returns></returns> public BaseResultModel <int> DeleteModel(List <Guid?> IDs) { SuccessResultModel <int> result = new SuccessResultModel <int>(); ErrorResultModel <int> error = new ErrorResultModel <int>(); try { ModelOutputModel selModel = new ModelOutputModel(); ModelInputModel inputModel = new ModelInputModel(); TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { foreach (Guid?item in IDs) { selModel = this.ModelRepository.SelectWithKeys(new ModelModel() { ModelID = item }); inputModel = new ModelInputModel() { ModelID = selModel.ModelID, ModelCode = selModel.ModelCode, IsDelete = true }; result.Data = this.ModelDetailRepository.UpdateWithModel(new ModelDetailModel() { IsDelete = true }, new ModelDetailModel() { ModelID = selModel.ModelID }); result.Data = this.ModelRepository.UpdateWithKeys(inputModel); this.ModelRepository.DelDBTable(inputModel); } scope.Complete(); } if (result.Data == 0) { error.ErrorCode = EnumErrorCode.业务执行失败; error.ErrorMessage = "请确认需要删除的数据!"; return(error); } return(result); } catch (Exception ex) { LogWriter.WriteLog(EnumLogLevel.Fatal, "DeleteModel", JsonConvert.SerializeObject(IDs), "Model", "删除模块表 (逻辑删除)异常!", ex); error.ErrorCode = EnumErrorCode.系统异常; error.ErrorMessage = "删除模块表 (逻辑删除)异常!"; return(error); } }
/// <summary> /// 删除模块明细表 (逻辑删除) /// </summary> /// <param name="IDs"></param> /// <returns></returns> public BaseResultModel <int> DeleteModelDetail(List <Guid?> IDs) { SuccessResultModel <int> result = new SuccessResultModel <int>(); ErrorResultModel <int> error = new ErrorResultModel <int>(); try { ModelDetailViewModel selDetailModel = new ModelDetailViewModel(); ModelOutputModel selModel = new ModelOutputModel(); TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; foreach (Guid?item in IDs) { using (this.ModelDetailRepository.BeginSelView()) { selDetailModel = this.ModelDetailRepository.SelectWithViewModel(new ModelDetailViewModel() { ModelDetailID = item, }); } if (this.ModelDetailRepository.ListDynamicTableListByPer(selDetailModel)) { error.ErrorCode = EnumErrorCode.业务执行失败; error.ErrorMessage = "该数据字段已有业务数据,不可删除"; return(error); } selDetailModel.IsDelete = true; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { result.Data = this.ModelDetailRepository.UpdateWithKeys(selDetailModel); this.ModelDetailRepository.DropDynamicTableCol(selDetailModel); scope.Complete(); } } if (result.Data == 0) { error.ErrorCode = EnumErrorCode.业务执行失败; error.ErrorMessage = "请确认需要删除的数据!"; return(error); } return(result); } catch (Exception ex) { LogWriter.WriteLog(EnumLogLevel.Fatal, "DeleteModelDetail", JsonConvert.SerializeObject(IDs), "ModelDetail", "删除模块明细表 (逻辑删除)异常!", ex); error.ErrorCode = EnumErrorCode.系统异常; error.ErrorMessage = "删除模块明细表 (逻辑删除)异常!"; return(error); } }
public BaseResultModel <TestOutputModel> CreateData(TestInputModel model) { try { var result = new SuccessResultModel <TestOutputModel>(); result.Data = this.TestTableRepository.InsertAndReturn(model); return(result); } catch (Exception e) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ListData", "", "", "创建数据时发生错误.", e); return(new ErrorResultModel <TestOutputModel>("", "创建数据时发生错误")); } }
public async Task <ActionResult> Get([FromQuery] VeiculoModel model) { var pontosCarteira = await _DetranVerificadorPontosCarteiraServices.ConsultarPontosCarteira(_Mapper.Map <Veiculo>(model)); //var result = new SuccessResultModel<IEnumerable<PontosCarteiraVeiculoModel>>(_Mapper.Map<IEnumerable<PontosCarteiraVeiculoModel>>(pontosCarteira)); var result = new SuccessResultModel <PontosCarteiraVeiculo>(new PontosCarteiraVeiculo { DataOcorrencia = System.DateTime.Now, Descricao = "teste", Pontos = 1 }); return(Ok(result)); }
public BaseResultModel <int> RemoveData(List <TestInputModel> model) { try { var result = new SuccessResultModel <int>(); result.Data = 0; foreach (var item in model) { result.Data += this.TestTableRepository.DeleteWithKeys(item); } return(result); } catch (Exception e) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ListData", "", "", "删除数据时发生错误.", e); return(new ErrorResultModel <int>("", "删除数据时发生错误")); } }
/// <summary> /// 新增、修改模块明细表 /// </summary> /// <param name="model"></param> /// <returns></returns> public BaseResultModel <ModelDetailOutputModel> ModifyModelDetail(ModelDetailInputModel model) { SuccessResultModel <ModelDetailOutputModel> result = new SuccessResultModel <ModelDetailOutputModel>(); ErrorResultModel <ModelDetailOutputModel> error = new ErrorResultModel <ModelDetailOutputModel>(); try { ModelOutputModel selModel = this.ModelRepository.SelectWithModel(new ModelModel() { ModelID = model.ModelID }); if (selModel == null) { return(new ErrorResultModel <ModelDetailOutputModel>(EnumErrorCode.参数校验未通过, "明细表对应的模块项目不存在!")); } ModelDetailViewModel selDetailModel = new ModelDetailViewModel(); using (this.ModelDetailRepository.BeginSelView()) { selDetailModel = this.ModelDetailRepository.SelectWithViewModel(new ModelDetailViewModel() { ModelID = model.ModelID, ColName = model.ColName }); } if (selDetailModel != null) { if (model.ModelDetailID.IsNullOrEmpty()) { return(new ErrorResultModel <ModelDetailOutputModel>(EnumErrorCode.参数校验未通过, "名称已存在!")); } else if (selDetailModel.ModelDetailID != model.ModelDetailID) { return(new ErrorResultModel <ModelDetailOutputModel>(EnumErrorCode.参数校验未通过, "名称已存在!")); } } selDetailModel = new ModelDetailViewModel(); selDetailModel.ModelCode = selModel.ModelCode; selDetailModel.ColName = model.ColName; selDetailModel.ColType = model.ColType; TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { if (model.ModelDetailID.IsNullOrEmpty()) { result.Data = this.ModelDetailRepository.InsertAndReturn(model); this.ModelDetailRepository.AddDynamicTableCol(selDetailModel); } else { result.Data = this.ModelDetailRepository.UpdateWithKeysAndReturn(model); this.ModelDetailRepository.ModifyDynamicTableCol(selDetailModel); } scope.Complete(); } return(result); } catch (Exception ex) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ModifyModelDetail", JsonConvert.SerializeObject(model), "ModelDetail", "新增、修改模块明细表异常!", ex); return(new ErrorResultModel <ModelDetailOutputModel>(EnumErrorCode.系统异常, "新增、修改模块明细表异常!")); } }