Beispiel #1
0
 private void Button_SWOTcompany_Click(object sender, RoutedEventArgs e)
 {
     using (var context = new CompanySWOTContext())
     {
         var currentCompany = (Company)listBox_companies.SelectedItem;
         var result         = context.CompanySWOT.FirstOrDefault(x => x.CompanyId == currentCompany.Id);
         _WindowSWOT = new WindowSWOT(currentCompany, result);
         if (!_WindowSWOT.IsVisible)
         {
             _WindowSWOT.Show();
         }
     }
 }
 private void Button_Save_Click(object sender, RoutedEventArgs e)
 {
     using (var context = new CompanySWOTContext()){
         var result = context.CompanySWOT.FirstOrDefault(x => x.CompanyId == _Company.Id);
         var swot   = ConvertSwotListsToStrings(_Company.Id, listBox_Strengths.Items, listBox_Opportunities.Items, listBox_Weaknesses.Items, listBox_Threats.Items);
         if (result == null)
         {
             context.CompanySWOT.Add(swot);
         }
         if (result != null)
         {
             result.Strengths     = swot.Strengths;
             result.Opportunities = swot.Opportunities;
             result.Threats       = swot.Threats;
             result.Weaknesses    = swot.Weaknesses;
         }
         context.SaveChanges();
     }
     this.Close();
 }