public async Task <IActionResult> Insert(RubroModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var rubro = _mapper.Map <RubroDto>(model); await _rubroRepositorio.Insertar(rubro); return(Ok(model)); }
public async Task <IActionResult> Edit(long id, RubroModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var rubro = _mapper.Map <RubroDto>(model); rubro.Id = id; await _rubroRepositorio.Modificar(rubro); return(Ok(model)); }
public List <RubroModel> SelectAllRubrosGastos() { DataSet ds = null; List <RubroModel> rubros = new List <RubroModel>(); using (var connection = GetConnection()) { connection.Open(); MySqlCommand command = new MySqlCommand("get_rubros_gastos", connection); command.CommandType = CommandType.StoredProcedure; MySqlDataAdapter adaptador = new MySqlDataAdapter(command); ds = new DataSet(); adaptador.Fill(ds); foreach (DataRow item in ds.Tables[0].Rows) { RubroModel rubro = new RubroModel(); rubro.Id = int.Parse(item["id"].ToString()); rubro.Descripcion = item["descripcion"].ToString(); rubros.Add(rubro); } } return(rubros); }