public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> dbQuery = _context.Set <T>();

            foreach (Expression <Func <T, object> > property in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(property);
            }
            return(dbQuery.ToList());
        }
        public void test()
        {
            OrderManagementContext         context = new OrderManagementContext();
            IEnumerable <OM_DepartmentDto> test1   = context.Set <OM_Permission>().Where(p => p.ID > 0).Select(p => Mapper.Map <OM_Permission, OM_DepartmentDto>(p));


            OM_Permission    permission = new OM_Permission();
            OM_DepartmentDto test       = Mapper.Map <OM_Permission, OM_DepartmentDto>(permission);
        }
Beispiel #3
0
        public bool BookYourTable(TblTableOrder tblTableOrder)
        {
            int?paymentId = null;

            if (tblTableOrder != null)
            {
                tblTableOrder.TblOrderStatusId = 1;
                tblTableOrder.TblPaymentTypeId = 4;
                tblTableOrder.UserCreated      = tblTableOrder.TblCustomerId.HasValue ? tblTableOrder.TblCustomerId.Value : 1;
                tblTableOrder.UserModified     = tblTableOrder.TblCustomerId.HasValue ? tblTableOrder.TblCustomerId.Value : 1;
                tblTableOrder.ToDate           = tblTableOrder.FromDate;

                _orderManagementContext.Set <TblTableOrder>().Add(tblTableOrder);
                _orderManagementContext.SaveChanges();

                return(true);
            }

            return(false);
        }
        public int AddCart(TblCart tblcart)
        {
            if (tblcart != null)
            {
                List <TblCart> cart = _context.TblCart.Where(ca => ca.TblCustomerID == tblcart.TblCustomerID).ToList <TblCart>();
                if (cart.Count() > 0)
                {
                    foreach (var item in cart)
                    {
                        if (tblcart.TblRestaurantID != item.TblRestaurantID)
                        {
                            _context.TblCart.RemoveRange(_context.TblCart.Where(c => c.TblCustomerID == tblcart.TblCustomerID));
                            tblcart.status       = true;
                            tblcart.UserCreated  = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                            tblcart.UserModified = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                            _context.Set <TblCart>().Add(tblcart);
                            _context.SaveChanges();
                            return(1);
                        }
                        if (tblcart.TblMenuID == item.TblMenuID)
                        {
                            item.TblCustomerID          = tblcart.TblCustomerID;
                            item.TblRestaurantID        = tblcart.TblRestaurantID;
                            item.TblMenuID              = tblcart.TblMenuID;
                            item.Price                  = tblcart.Price;
                            item.Quantity               = tblcart.Quantity;
                            item.status                 = tblcart.status;
                            item.RecordTimeStampCreated = DateTime.Now;
                            item.offer                  = tblcart.offer;
                            item.RecordTimeStamp        = DateTime.Now;
                            _context.SaveChanges();
                            return(1);
                        }
                        if (tblcart.TblRestaurantID == item.TblRestaurantID && tblcart.TblMenuID != item.TblMenuID)
                        {
                            tblcart.status       = true;
                            tblcart.UserCreated  = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                            tblcart.UserModified = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                            _context.Set <TblCart>().Add(tblcart);
                            _context.SaveChanges();
                            return(1);
                        }
                    }
                }
                else
                {
                    tblcart.status       = true;
                    tblcart.UserCreated  = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                    tblcart.UserModified = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                    _context.Set <TblCart>().Add(tblcart);
                    _context.SaveChanges();
                    return(1);
                }


                //if (cart != null)
                //{
                //    if (cart.TblRestaurantID != tblcart.TblRestaurantID )
                //    {
                //        _context.TblCart.RemoveRange(_context.TblCart.Where(c => c.TblCustomerID == tblcart.TblCustomerID));
                //        //List<TblCart> removecartlist = _context.TblCart.Where(d => d.TblCustomerID == tblcart.TblCustomerID).ToList<TblCart>();
                //        //_context.Remove(removecartlist);
                //        //_context.SaveChanges();
                //        tblcart.status = true;
                //        tblcart.UserCreated = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                //        tblcart.UserModified = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                //        _context.Set<TblCart>().Add(tblcart);
                //        _context.SaveChanges();
                //        return 1;
                //    }
                //    else if (cart.TblRestaurantID == tblcart.TblRestaurantID && cart.TblMenuID == tblcart.TblMenuID)
                //    {
                //        cart.TblCustomerID = tblcart.TblCustomerID;
                //        cart.TblRestaurantID = tblcart.TblRestaurantID;
                //        cart.TblMenuID = tblcart.TblMenuID;
                //        cart.Price = tblcart.Price;
                //        cart.Quantity = tblcart.Quantity;
                //        cart.status = tblcart.status;
                //        cart.RecordTimeStampCreated = DateTime.Now;
                //        cart.offer = tblcart.offer;
                //        cart.RecordTimeStamp = DateTime.Now;
                //        _context.SaveChanges();
                //        return 1;
                //    }
                //    else
                //    {
                //        tblcart.status = true;
                //        tblcart.UserCreated = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                //        tblcart.UserModified = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                //        _context.Set<TblCart>().Add(tblcart);
                //        _context.SaveChanges();
                //        return 1;
                //    }
                //}
                //else
                //{
                //    tblcart.status = true;
                //    tblcart.UserCreated = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                //    tblcart.UserModified = tblcart.TblCustomerID.HasValue ? tblcart.TblCustomerID.Value : 1;
                //    _context.Set<TblCart>().Add(tblcart);
                //    _context.SaveChanges();
                //    return 1;
                //}
            }

            return(0);
        }
 public virtual IEnumerable <T> GetAll()
 {
     return(_context.Set <T>().ToList());
 }