public MenuItem GetMenuItem(long menuItemId) { MenuItem menuItems = null; using (_sqlConnection = new SqlConnection(ConnectionHandler.GetConnection)) { using (_sqlCommand = new SqlCommand()) { _sqlCommand.Connection = _sqlConnection; _sqlCommand.CommandText = CommandHelper.MenuItemList; _sqlCommand.Parameters.AddWithValue("@id", menuItemId); _sqlConnection.Open(); _sqlDataReader = _sqlCommand.ExecuteReader(); while (_sqlDataReader.Read()) { menuItems = new MenuItem { Id = long.Parse(_sqlDataReader[0].ToString()), Name = _sqlDataReader[1].ToString(), Price = float.Parse(_sqlDataReader[2].ToString()), Active = bool.Parse(_sqlDataReader[3].ToString()), DateOfLaunch = DateUtility.ConvertToDate(_sqlDataReader[4].ToString()), Category = _sqlDataReader[5].ToString(), FreeDelivery = bool.Parse(_sqlDataReader[6].ToString()) }; } } } return(menuItems); }
public List <MenuItem> GetMenuItemListCustomer() { List <MenuItem> menuItems = new List <MenuItem>(); using (_sqlConnection = new SqlConnection(ConnectionHandler.GetConnection)) { using (_sqlCommand = new SqlCommand()) { _sqlCommand.Connection = _sqlConnection; _sqlCommand.CommandText = CommandHelper.MenuItemListCustomer; _sqlConnection.Open(); _sqlDataReader = _sqlCommand.ExecuteReader(); while (_sqlDataReader.Read()) { menuItems.Add(new MenuItem { Id = long.Parse(_sqlDataReader[0].ToString()), Name = _sqlDataReader[1].ToString(), Price = float.Parse(_sqlDataReader[2].ToString()), Active = bool.Parse(_sqlDataReader[3].ToString()), DateOfLaunch = DateUtility.ConvertToDate(_sqlDataReader[4].ToString()), Category = _sqlDataReader[5].ToString(), FreeDelivery = bool.Parse(_sqlDataReader[6].ToString()) }); } } } return(menuItems); }
public Cart GetAllCartItems(long userId) { List <MenuItem> menuItems = new List <MenuItem>(); using (_sqlConnection = new SqlConnection(ConnectionHandler.GetConnection)) { using (_sqlCommand = new SqlCommand()) { _sqlCommand.Connection = _sqlConnection; _sqlCommand.CommandText = CommandHelper.GetAllCartItems; _sqlCommand.Parameters.AddWithValue("@userId", userId); _sqlDataReader = _sqlCommand.ExecuteReader(); while (_sqlDataReader.Read()) { menuItems.Add(new MenuItem { Id = long.Parse(_sqlDataReader[0].ToString()), Name = _sqlDataReader[1].ToString(), Price = float.Parse(_sqlDataReader[2].ToString()), Active = bool.Parse(_sqlDataReader[3].ToString()), DateOfLaunch = DateUtility.ConvertToDate(_sqlDataReader[4].ToString()), Category = _sqlDataReader[5].ToString(), FreeDelivery = bool.Parse(_sqlDataReader[6].ToString()) }); } } } Cart cart = new Cart(menuItems, 0); if (cart == null) { throw new CartEmptyException(); } return(cart); }
static public void FavoritesListInitialization() { if (favoritesmovielist == null) { favoritesmovielist = new List <Movie>() { new Movie() { Id = 1, Title = "Avatar", BoxOffice = "$2,787,965,087", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("15/03/2017"), Genre = "Science Fiction", HasTeaser = "Yes" }, new Movie() { Id = 2, Title = "The Avengers", BoxOffice = "$1,518,812,988", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("23/12/2017"), Genre = "Superhero", HasTeaser = "No" }, new Movie() { Id = 3, Title = "Titanic", BoxOffice = "$2,187,463,944", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("21/08/2017"), Genre = "Romance", HasTeaser = "No" }, }; } }
public MenuItemDaoCollection() { if (menuItemList == null) { menuItemList = new List <MenuItem>(); // Create static menuItems to add menuItemList MenuItem menuItem1 = new MenuItem(1001, "Sandwich", 99.00f, true, DateUtility.ConvertToDate("15/03/2017"), "Main Course", true); MenuItem menuItem2 = new MenuItem(1002, "Burger", 129.00f, true, DateUtility.ConvertToDate("23/12/2017"), "Main Course", false); MenuItem menuItem3 = new MenuItem(1003, "Pizza", 149.00f, true, DateUtility.ConvertToDate("21/08/2018"), "Main Course", false); MenuItem menuItem4 = new MenuItem(1004, "French Fries", 57.00f, false, DateUtility.ConvertToDate("02/07/2017"), "Starters", true); MenuItem menuItem5 = new MenuItem(1005, "Choclate Brownie", 32.00f, true, DateUtility.ConvertToDate("02/11/2022"), "Dessert", true); // Add menuItems to menuItemList menuItemList.Add(menuItem1); menuItemList.Add(menuItem2); menuItemList.Add(menuItem3); menuItemList.Add(menuItem4); menuItemList.Add(menuItem5); } }
protected void Button1_Click(object sender, EventArgs e) { MovieDaoCollection.ListOfMovies(); //MovieDaoCollection movieDao = new MovieDaoCollection(); int id = Convert.ToInt32(Request.QueryString["id"].ToString()); //Movie obj = (from x in movieDao.movieList // where x.Id == id // select x).FirstOrDefault(); string active; string hasTeaser; if (Radioyes.Checked) { active = "Yes"; } else { active = "No"; } if (CheckBox1.Checked) { hasTeaser = "Yes"; } else { hasTeaser = "No"; } MovieDaoCollection.movielist.Where(w => w.Id == id).ToList().ForEach(i => { i.Title = TxtTitle.Text; i.BoxOffice = TxtGross.Text; i.Active = active; i.DateOfLaunch = DateUtility.ConvertToDate(TxtDate.Text); i.Genre = DropDownList1.SelectedValue; i.HasTeaser = hasTeaser; }); Response.Redirect("EditMovieStatus.aspx"); }
public void ModifyMovie(Movie movie) { foreach (Movie m in movielist) { if (m == movie) { Console.WriteLine("Enter The Title you want to edit"); m.Title = Console.ReadLine(); Console.WriteLine("Enter Boxoffice"); m.BoxOffice = Console.ReadLine(); Console.WriteLine("Enter Active"); m.Active = Console.ReadLine(); Console.WriteLine("Enter Dateoflaunch"); m.DateOfLaunch = DateUtility.ConvertToDate(Console.ReadLine()); Console.WriteLine("Enter genre"); m.Genre = Console.ReadLine(); Console.WriteLine("Enter Hasteaser"); m.HasTeaser = Console.ReadLine(); Console.WriteLine("Selected Record Updated Succesfully"); } } }
static public void ListOfMovies() { if (movielist == null) { movielist = new List <Movie>() { new Movie() { Id = 1, Title = "Avatar", BoxOffice = "$2,787,965,087", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("15/03/2017"), Genre = "Science Fiction", HasTeaser = "Yes" }, new Movie() { Id = 2, Title = "The Avengers", BoxOffice = "$1,518,812,988", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("23/12/2017"), Genre = "Superhero", HasTeaser = "No" }, new Movie() { Id = 3, Title = "Titanic", BoxOffice = "$2,187,463,944", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("21/08/2017"), Genre = "Romance", HasTeaser = "No" }, new Movie() { Id = 4, Title = "Jurassic World", BoxOffice = "$1,617,713,208", Active = "No", DateOfLaunch = DateUtility.ConvertToDate("02/07/2017"), Genre = "Science Fiction", HasTeaser = "Yes" }, new Movie() { Id = 5, Title = "Avengers", BoxOffice = "$2,750,760,348", Active = "Yes", DateOfLaunch = DateUtility.ConvertToDate("02/11/2022"), Genre = "Superhero", HasTeaser = "Yes" }, }; } }
public MenuItemDaoCollection() { if (menuItemList == null) { menuItemList = new List <MenuItem>(); menuItemList.Add(new MenuItem(id: 1, name: "Sandwich", price: 99.00f, active: true, dateOfLaunch: DateUtility.ConvertToDate("2017/03/15"), category: "Main Course", freeDelivery: true)); menuItemList.Add(new MenuItem(id: 2, name: "Burger", price: 129.00f, active: true, dateOfLaunch: DateUtility.ConvertToDate("2017/12/23"), category: "Main Course", freeDelivery: false)); menuItemList.Add(new MenuItem(id: 3, name: "Pizza", price: 149.00f, active: true, dateOfLaunch: DateUtility.ConvertToDate("2018/08/21"), category: "Main Course", freeDelivery: false)); menuItemList.Add(new MenuItem(id: 4, name: "French Fries", price: 57.00f, active: false, dateOfLaunch: DateUtility.ConvertToDate("2017/07/02"), category: "Starters", freeDelivery: true)); menuItemList.Add(new MenuItem(id: 5, name: "Chocolate Brownie", price: 32.00f, active: true, dateOfLaunch: DateUtility.ConvertToDate("2022/11/02"), category: "Dessert", freeDelivery: true)); } }
public static void TestModifyMenuItem() { MenuItem menuItem = new MenuItem(id: 2, name: "Burger", price: 129.00f, active: true, dateOfLaunch: DateUtility.ConvertToDate("2017/12/23"), category: "Main Course", freeDelivery: false); MenuItemDaoCollection menuItemDao = new MenuItemDaoCollection(); menuItemDao.ModifyMenuItem(menuItem); }