public void addSuggestion() { Console.Clear(); try { Console.WriteLine("Enter client ID "); int id = Convert.ToInt32(Console.ReadLine()); Client client = searchClientByID(id); Console.WriteLine("Enter number of real estates (1-4) "); int number = Convert.ToInt32(Console.ReadLine()); Suggestion s = new Suggestion { Client = client }; businessLogic.AddSuggestion(s); for (int i = 0; i < number; i++) { Console.WriteLine("Enter real estate ID "); int reID = Convert.ToInt32(Console.ReadLine()); RealEstate realEstate = searchRealEstateByID(reID); RealEstateSuggestion res = new RealEstateSuggestion { Suggestion = s, RealEstate = realEstate }; businessLogic.AddRealEstateSuggestion(res); realEstate.RealEstateSuggestions.Add(res); s.RealEstateSuggestions.Add(res); } businessLogic.Commit(); } catch (Exception e) { Console.WriteLine(e.Message); Console.Write("Press Eneter key to continue.. "); Console.ReadLine(); } }
public void DeleteRealEstateSuggestion(RealEstateSuggestion realEstateSuggestion) { context.RealEstateSuggestions.Remove(realEstateSuggestion); context.SaveChanges(); }
public void AddRealEstateSuggestion(RealEstateSuggestion realEstateSuggestion) { context.RealEstateSuggestions.Add(realEstateSuggestion); context.SaveChanges(); }