コード例 #1
0
 public bool CreatePizza(Pizza pizza)
 {
     try
     {
         DatabasePizzaEntities db = new DatabasePizzaEntities();
         db.Pizzas.Add(pizza);
         db.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 public bool SignUp(Customer customer)
 {
     try
     {
         DatabasePizzaEntities db = new DatabasePizzaEntities();
         db.Customers.Add(customer);
         db.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }