public ApiResponse Update(int id, TipoUsuario tipoUsuario) { ApiResponse resp = this.ValidateTipoUsuario(tipoUsuario); if (resp.Success == false) { return(resp); } else { resp = new ApiResponse(); } if (id <= 0) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Nivel usuario nao informado"); return(resp); } DAOBase <TipoUsuario> dao = new DAOBase <TipoUsuario>(); TipoUsuario n = dao.GetById(id); if (n == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Nivel de usuario: " + id + " informado inexistente"); return(resp); } // atribuicoes de campos n.id_alcada = tipoUsuario.id_alcada; n.s_codigo = tipoUsuario.s_codigo; n.s_descricao = tipoUsuario.s_descricao; try { dao.Update(n); resp.Success = true; resp.data = n; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }
/// <summary> /// 修改字典 /// </summary> /// <param name="dict"></param> /// <returns></returns> public MsgEntity EditDict(T_Sys_Dict dict) { MsgEntity me = new MsgEntity(); if (dict == null || string.IsNullOrEmpty(dict.DICT_CODE)) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "字典编码不能为空"; return(me); } //查找关键字是否有相同值(不同id的dict_code不能相同) PredicateGroup pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; pg.Predicates.Add(Predicates.Field <T_Sys_Dict>(f => f.DICT_CODE, Operator.Eq, dict.DICT_CODE)); pg.Predicates.Add(Predicates.Field <T_Sys_Dict>(f => f.ID, Operator.Eq, dict.ID, true)); int count = dao.Count <T_Sys_Dict>(pg); if (count > 0) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "字典编码重复"; return(me); } bool result = false; try { result = dao.Update <T_Sys_Dict>(dict); me.MsgCode = MsgEntity.MsgCodeEnum.Success; me.MsgDes = "字典编辑成功"; } catch (Exception ex) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = ex.Message; } return(me); }
public ApiResponse Update(int id, Alcada alcada) { ApiResponse resp = new ApiResponse(); if (alcada == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Conteudo vazio"); return(resp); } if (string.IsNullOrEmpty(alcada.s_descricao) == true) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Descricao nao informada"); return(resp); } DAOBase <Alcada> daoA = new DAOBase <Alcada>(); Alcada a = daoA.GetById(id); if (a == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Alcada: " + alcada + " informada inexistente"); return(resp); } // atriuicao dos valores a.s_descricao = alcada.s_descricao; try { daoA.Update(a); resp.Success = true; resp.data = a; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }
public ApiResponse Update(int id, TipoParticipante tipoParticipante) { ApiResponse resp = new ApiResponse(); if (tipoParticipante == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Conteudo vazio"); return(resp); } if (string.IsNullOrEmpty(tipoParticipante.s_descricao) == true) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Descricao nao informada"); return(resp); } DAOBase <TipoParticipante> daoA = new DAOBase <TipoParticipante>(); TipoParticipante a = daoA.GetById(id); if (a == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("TipoParticipante: " + tipoParticipante + " informada inexistente"); return(resp); } // atriuicao dos valores a.s_descricao = tipoParticipante.s_descricao; try { daoA.Update(a); resp.Success = true; resp.data = a; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }
public ApiResponse Update(int id, Empresa empresa) { ApiResponse resp = this.ValidateEmpresa(empresa); if (resp.Success == false) { return(resp); } else { resp = new ApiResponse(); } if (id <= 0) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Empresa nao informada"); return(resp); } DAOBase <Empresa> dao = new DAOBase <Empresa>(); Empresa n = dao.GetById(id); if (n == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Empresa: " + id + " informada inexistente"); return(resp); } // campos empresa.id = id; try { dao.Update(empresa); resp.Success = true; resp.data = empresa; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }
/// <summary> /// 编辑 /// </summary> /// <param name="category"></param> /// <returns></returns> public MsgEntity Edit(T_EC_KWCategory category) { MsgEntity me = new MsgEntity(); if (category == null || string.IsNullOrEmpty(category.CATEGORY_CODE) || string.IsNullOrEmpty(category.CATEGORY_NAME)) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "编码或名称不能为空"; return(me); } //查找关键字是否有相同值(不同id的dict_code不能相同) PredicateGroup pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; pg.Predicates.Add(Predicates.Field <T_EC_KWCategory>(f => f.CATEGORY_CODE, Operator.Eq, category.CATEGORY_CODE)); pg.Predicates.Add(Predicates.Field <T_EC_KWCategory>(f => f.ID, Operator.Eq, category.ID, true)); int count = dao.Count <T_EC_KWCategory>(pg); if (count > 0) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "编码重复"; return(me); } bool result = false; try { result = dao.Update <T_EC_KWCategory>(category); me.MsgCode = MsgEntity.MsgCodeEnum.Success; me.MsgDes = "编辑成功"; } catch (Exception ex) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = ex.Message; } return(me); }
public ApiResponse Update(int id, Usuario usuario) { ApiResponse resp = this.ValidateUsuario(usuario); if (resp.Success == false) { return(resp); } else { resp = new ApiResponse(); } if (id <= 0) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Usuario nao informado"); return(resp); } DAOBase <Usuario> dao = new DAOBase <Usuario>(); Usuario n = dao.GetById(id); if (n == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Nivel de usuario: " + id + " informado inexistente"); return(resp); } // atribuicoes de campos n.b_emailseg = usuario.b_emailseg; n.b_email_ssl = usuario.b_email_ssl; n.id_nivel_usuario = usuario.id_nivel_usuario; n.id_tipo_usuario = usuario.id_tipo_usuario; n.n_emailporta = usuario.n_emailporta; n.s_emailcopia = usuario.s_emailcopia; n.s_emailhost = usuario.s_emailhost; n.s_emaillogin = usuario.s_emaillogin; n.s_emailnome = usuario.s_emailnome; n.s_emailsenha = usuario.s_emailsenha; n.s_nome = usuario.s_nome; n.b_usuario_pf = usuario.b_usuario_pf; n.s_cpf_cnpj = usuario.s_cpf_cnpj; n.id_tipo_participante = usuario.id_tipo_participante; n.id_grupo_participante = usuario.id_grupo_participante; try { dao.Update(n); resp.Success = true; resp.data = n; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }