public static void AddResteraunt(Resteraunt res) { ResterauntRepository resterauntRepository = new ResterauntRepository(); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DataContext"].ConnectionString); SqlCommand cmd; SqlDataAdapter da; try { using (con) { string cmdText = $"Insert into Resteraunts(Name, City )values(' {res.Name}', '{res.City}')"; con.Open(); cmd = new SqlCommand(cmdText, con); cmd.ExecuteNonQuery(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { con.Close(); } }
static void Main(string[] args) { ResterauntFunctions rest = new ResterauntFunctions(); ReviewFunctions rev = new ReviewFunctions(); Resteraunt resteraunt = new Resteraunt() { Name = "Bobs Burgers", City = "Ft. Lauderdale" }; // ResterauntCrudOps.AddResteraunt(resteraunt); ReviewsRepository revi = new ReviewsRepository(); // revi.TableToXml(); UserInputHandler.UserCommandOptions(); Console.ReadLine(); }
public virtual void DeleteAndSubmit(Resteraunt entity) { this.dataContext.Set <Resteraunt>().Remove(entity); this.SaveChanges(); }
public void InsertResteraunt(Resteraunt entity) { dataContext.Resteraunts.Add(entity); dataContext.SaveChanges(); }