private void btnSalvar_Click(object sender, EventArgs e) { try { if (valida()) { if (_categoria == null) { Categoria categoria = new Categoria(); categoria.Nome = this.txtCategoria.Text; ServiceCategoria serviceCategoria = new ServiceCategoria(); serviceCategoria.Create(categoria); } else { ServiceCategoria serviceCategoria = new ServiceCategoria(); Categoria categoria = serviceCategoria.FindCategoria(_categoria.Id); categoria.Nome = this.txtCategoria.Text; serviceCategoria.update(); } this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void carregaCombobox() { ServiceCategoria serviceCategoria = new ServiceCategoria(); this.cboCategoria.DataSource = serviceCategoria.ListCategoria(); this.cboCategoria.SelectedIndex += -1; }
//Métodos private void carregaComboBox() { ServiceCor serviceCor = new ServiceCor(); this.cboCor.DataSource = serviceCor.ListCor(); this.cboCor.SelectedIndex += -1; ServiceCategoria serviceCategoria = new ServiceCategoria(); this.cboCategoria.DataSource = serviceCategoria.ListCategoria(); this.cboCategoria.SelectedIndex += -1; this.cboAcessorio.DataSource = Enum.GetValues(typeof(EnumAcessorio)); this.cboAcessorio.SelectedIndex += -1; }
private void btnExcluir_Click(object sender, EventArgs e) { try { if (_categoria != null) { ServiceCategoria serviceCategoria = new ServiceCategoria(); serviceCategoria.Delete(_categoria); this.Close(); } } catch (Exception) { throw; } }
public CategoriaController(ServiceCategoria serviceCategoria, IMapper mapper) { this.serviceCategoria = serviceCategoria; this.mapper = mapper; }
public CadastroController(ServiceCategoria serviceCategoria, ServiceReceita serviceReceita, AutoMapper.IMapper mapper) { this.serviceCategoria = serviceCategoria; this.serviceReceita = serviceReceita; this.mapper = mapper; }