Exemple #1
0
        /// <summary>
        /// Update an entry in the database
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Name"></param>
        /// <param name="Price"></param>
        public void UpdateMenuItem(int Id, string Name, decimal Price)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GetConnectionString.CnnVal("Menu")))
            {
                MenuItemModel menuItem = new MenuItemModel();
                menuItem.Id    = Id;
                menuItem.Price = Price;
                menuItem.Name  = Name;

                connection.Execute("dbo.UpdateMenuItem @Id, @Price, @Name", menuItem);
            }
        }
Exemple #2
0
        /// <summary>
        /// Removes an entry from the database
        /// </summary>
        /// <param name="anId"></param>
        public void RemoveMenuItem(int anId)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GetConnectionString.CnnVal("Menu")))
            {
                MenuItemModel menuItem = new MenuItemModel();
                menuItem.Id = anId;

                connection.Execute("dbo.RemoveMenuItem @Id", menuItem);
            }
        }
Exemple #3
0
 /// <summary>
 /// Returns a list of menu items specified by the argument (starter, main, drink etc)
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public List <MenuItemModel> GetItemsFromCategory(string category)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GetConnectionString.CnnVal("Menu")))
     {
         var output = connection.Query <MenuItemModel>("dbo.GetItemsFromCategory @Category", new { Category = category }).ToList();
         return(output);
     }
 }
Exemple #4
0
        /// <summary>
        /// Add a new database entry
        /// </summary>
        /// <param name="name"></param>
        /// <param name="price"></param>
        /// <param name="category"></param>
        public void AddMenuItem(string name, decimal price, string category)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GetConnectionString.CnnVal("Menu")))
            {
                MenuItemModel menuItem = new MenuItemModel();
                menuItem.Name     = name;
                menuItem.Price    = price;
                menuItem.Category = category;

                connection.Execute("dbo.AddMenuItem @Name, @Price, @Category", menuItem);
            }
        }
Exemple #5
0
 /// <summary>
 /// Pulls all the data from the SQL server
 /// </summary>
 /// <returns>A list of ContactModel</returns>
 public List <MenuItemModel> Startup()
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GetConnectionString.CnnVal("Menu")))
     {
         var output = connection.Query <MenuItemModel>("dbo.Startup").ToList();
         return(output);
     }
 }