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();
            }
        }
예제 #2
0
        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();
        }
예제 #3
0
 public virtual void DeleteAndSubmit(Resteraunt entity)
 {
     this.dataContext.Set <Resteraunt>().Remove(entity);
     this.SaveChanges();
 }
예제 #4
0
 public void InsertResteraunt(Resteraunt entity)
 {
     dataContext.Resteraunts.Add(entity);
     dataContext.SaveChanges();
 }