public bool CreatePizza(Pizza pizza) { try { DatabasePizzaEntities db = new DatabasePizzaEntities(); db.Pizzas.Add(pizza); db.SaveChanges(); return true; } catch (Exception e) { return false; } }
public List<Order> GetAllOrders() { DatabasePizzaEntities db = new DatabasePizzaEntities(); var orders = db.Orders; List<Order> ordersList = null; if (orders != null) { ordersList = new List<Order>(); } foreach (var order in orders) { ordersList.Add(order); } return ordersList; }
public string Login(string phoneNo, string password) { try { decimal phoneNoDecimal = Decimal.Parse(phoneNo); DatabasePizzaEntities db = new DatabasePizzaEntities(); Customer customer = db.Customers.Where(c => c.PhoneNo == phoneNoDecimal && c.Password == password).SingleOrDefault(); if (customer == null) return "false"; return "true"; } catch (Exception e) { return "I'm here"+e.InnerException.ToString(); } }
public List<OrderDetail> GetOrderDetails(string orderId) { int orderIdInt = Int32.Parse(orderId); DatabasePizzaEntities db = new DatabasePizzaEntities(); var orderDetails = db.OrderDetails.Where(o => o.OrderId == orderIdInt); List<OrderDetail> orderDetailsList = null; if (orderDetails != null) { orderDetailsList = new List<OrderDetail>(); } foreach (var order in orderDetails) { orderDetailsList.Add(order); } return orderDetailsList; }
public bool OrderPizza(Order order, List<OrderDetail> orderDetails) { try { DatabasePizzaEntities db = new DatabasePizzaEntities(); db.Orders.Add(order); foreach (var orderDetail in orderDetails) { db.OrderDetails.Add(orderDetail); } db.SaveChanges(); return true; } catch { return false; } }
public bool SignUp(Customer customer) { try { DatabasePizzaEntities db = new DatabasePizzaEntities(); db.Customers.Add(customer); db.SaveChanges(); return true; } catch (Exception e) { return false; } }