public IActionResult AlterarCstPis([FromBody] CstPis objJson, int id) { try { if (!ModelState.IsValid) { return(StatusCode(400, new RetornoJsonErro(400, "Objeto inválido [Alterar CstPis]", null))); } if (objJson.Id != id) { return(StatusCode(400, new RetornoJsonErro(400, "Objeto inválido [Alterar CstPis] - ID do objeto difere do ID da URL.", null))); } var objBanco = _repository.CstPis.ConsultarObjeto(objJson.Id); if (objBanco == null) { return(StatusCode(400, new RetornoJsonErro(400, "Objeto com ID inválido [Alterar CstPis]", null))); } _repository.CstPis.Alterar(objBanco, objJson); return(ConsultarObjetoCstPis(id)); } catch (Exception ex) { return(StatusCode(500, new RetornoJsonErro(500, "Erro no Servidor [Alterar CstPis]", ex))); } }
public static void Inicio(ISession session) { string path = AppDomain.CurrentDomain.BaseDirectory + "arquivos\\"; var arqCstIcms = new StreamReader(path + "cstIcms.txt"); var arqCstPis = new StreamReader(path + "cstPis.txt"); var arqCstCofins = new StreamReader(path + "cstCofins.txt"); string lineCstIcms = ""; string lineCstPis = ""; string lineCstCofins = ""; while (lineCstIcms != null) { lineCstIcms = arqCstIcms.ReadLine(); if (lineCstIcms != null && !lineCstIcms.Equals("")) { string[] split = lineCstIcms.Split(';'); var cst = new Cst { Codigo = split[0], Descricao = "'" + split[1] + "'", Origem = split[0].Substring(0, 1) }; session.Save(cst); } } while (lineCstPis != null) { lineCstPis = arqCstPis.ReadLine(); if (lineCstPis != null && !lineCstPis.Equals("")) { string[] split = lineCstPis.Split(';'); var cstPis = new CstPis { Cst = split[0], Descricao = "'" + split[1] + "'" }; session.Save(cstPis); } } while (lineCstCofins != null) { lineCstCofins = arqCstCofins.ReadLine(); if (lineCstCofins != null && !lineCstCofins.Equals("")) { string[] split = lineCstCofins.Split(';'); var cstCofins = new CstCofins { Codigo = split[0], Descricao = "'" + split[1] + "'" }; session.Save(cstCofins); } } }
public IActionResult InserirCstPis([FromBody] CstPis objJson) { try { if (!ModelState.IsValid) { return(StatusCode(400, new RetornoJsonErro(400, "Objeto inválido [Inserir CstPis]", null))); } _repository.CstPis.Inserir(objJson); return(CreatedAtRoute("ConsultarObjetoCstPis", new { id = objJson.Id }, objJson)); } catch (Exception ex) { return(StatusCode(500, new RetornoJsonErro(500, "Erro no Servidor [Inserir CstPis]", ex))); } }
public static void Map(this CstPis objBanco, CstPis objJson) { objBanco.Codigo = objJson.Codigo; objBanco.Descricao = objJson.Descricao; objBanco.Observacao = objJson.Observacao; }