Beispiel #1
0
        public void AddOrder(Order order)
        {
            List <Order> list      = new List <Order>();
            var          orderList = _context.Orders.Where(x => x.userPlacedBy == order.userPlacedBy && x.userPlacedTo == order.userPlacedTo && (x.orderStatus != "COMPLETED" && x.orderStatus != "CANCELLED")).FirstOrDefault();

            if (orderList != null)
            {
                throw new Exception("Can not place more than 1 order to one user at a time.");
            }

            foreach (FoodItemDetail item in order.foodItems)
            {
                Order orderItem = new Order();
                orderItem.createTime   = order.createTime;
                orderItem.orderID      = order.orderID;
                orderItem.orderStatus  = order.orderStatus;
                orderItem.sellerItemId = item.itemID;
                orderItem.id           = Guid.NewGuid().ToString();
                orderItem.userPlacedBy = order.userPlacedBy;
                orderItem.userPlacedTo = order.userPlacedTo;
                orderItem.quantity     = item.quantity;
                list.Add(orderItem);
            }
            _context.Orders.AddRange(list);
            _context.SaveChanges();
        }
Beispiel #2
0
 public void AddUser(User user)
 {
     if (UserExists(user.userUid))
     {
         throw new Exception("User Already Exists");
     }
     else
     {
         _context.Users.Add(user);
         _context.SaveChanges();
     }
 }
Beispiel #3
0
 public void AddSellerItem(SellerItem SellerItem)
 {
     _context.SellerItems.Add(SellerItem);
     _context.SaveChanges();
 }
Beispiel #4
0
 public void AddFoodItem(FoodItem FoodItem)
 {
     _context.FoodItems.Add(FoodItem);
     _context.SaveChanges();
 }
Beispiel #5
0
 public void AddFlat(Flat Flat)
 {
     _context.Flats.Add(Flat);
     _context.SaveChanges();
 }
Beispiel #6
0
 public void AddApartment(Apartment apartment)
 {
     _context.Apartments.Add(apartment);
     _context.SaveChanges();
 }
 public void AddUserTokenEntry(UserNotification UserNotification)
 {
     context.UserNotification.Add(UserNotification);
     context.SaveChanges();
 }