Witam, czy jest możliwość wybrania kategori już wcześniej wpisanej i zapianie jej w bazie danych sql?
private void NewAdvertBtn_Click(object sender, EventArgs e)
{
AdvertRepo repo = new AdvertRepo();
Category category = new Category();
User user = new User();
UserRepo userRepo = new UserRepo();
if (TitleBox.Text != "")
{
Advert advert = new Advert();
advert.Title = TitleBox.Text;
advert.Price = PriceBox.Text;
advert.Description = DescriptionBox.Text;
advert.UserID = userRepo.GetLoggedInUser().UsersID;
advert.Category.CategoryName = CategoryComboBox.SelectedIndex.ToString();
repo.InsertNewAdvert(advert);
}
else
{
MessageBox.Show("All informations must be filled");
}
}