protected void ButtonSubmitCaregory_Click(object sender, EventArgs e) { string name = this.TextBoxCategoryName.Text; string description = this.TextBoxCaragoryDescription.Text; Category category = new Category () { Name = name, Description = description }; ApplicationDbContext context = new ApplicationDbContext(); context.Categories.Add(category); context.SaveChanges(); }
protected void ButtonSubmitCaregory_Click(object sender, EventArgs e) { string name = this.TextBoxCategoryName.Text; string description = this.TextBoxCaragoryDescription.Text; if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(description)) { throw new ArgumentException(); } Category category = new Category () { Name = name, Description = description }; ApplicationDbContext context = new ApplicationDbContext(); context.Categories.Add(category); context.SaveChanges(); }