예제 #1
0
        public async System.Threading.Tasks.Task <T> Add(T entity)
        {
            _ctx.Set <T>().Add(entity);
            await _ctx.SaveChangesAsync();

            return(entity);
        }
예제 #2
0
        public async Task <List <Table> > TableList(string userName)
        {
            var user = await _userManager.FindByNameAsync(userName);

            var masalar = _context.Set <Table>().Where(x => x.RestaurantId == user.Id).ToList();

            return(masalar);
        }
        public async Task <ActionResult <OrderMaster> > GetOrderMaster(long id)
        {
            // var orderMaster = await _context.OrderMasters.FindAsync(id);
            var orderDetails = await(from master in _context.Set <OrderMaster>()
                                     join detail in _context.Set <OrderDetail>()
                                     on master.OrderMasterId equals detail.OrderMasterId
                                     join foodItem in _context.Set <FoodItem>()
                                     on detail.FoodItemId equals foodItem.FoodItemId
                                     where master.OrderMasterId == id
                                     select new
            {
                master.OrderMasterId,
                detail.OrderDetailId,
                detail.FoodItemId,
                detail.Quantity,
                detail.FoodItemPrice,
                foodItem.FoodItemName
            }
                                     ).ToListAsync();
            // array
            // get fooditem from order details
            // get order master
            var orderMaster = await(from a in _context.Set <OrderMaster>()
                                    where a.OrderMasterId == id
                                    select new
            {
                a.OrderMasterId,
                a.OrderNumber,
                a.CustomerId,
                a.PMethod,
                a.GTotal,
                deletedOrderItemIds = "",
                orderDetails        = orderDetails
            }
                                    ).FirstOrDefaultAsync();

            if (orderMaster == null)
            {
                return(NotFound());
            }

            return(Ok(orderMaster));
        }
예제 #4
0
        public async Task <IdentityResult> NewRestaurant(NewRestaurantDto model)
        {
            IdentityResult result = new IdentityResult();
            var            user   = new Restaurant
            {
                Email    = model.Email,
                UserName = model.UserName
            };

            result = await _userManager.CreateAsync(user, model.Password);

            var temp = await _userManager.FindByNameAsync(user.UserName);

            RestaurantAddress adres = new RestaurantAddress
            {
                Restaurant   = temp,
                RestaurantId = user.Id
            };

            _context.Set <RestaurantAddress>().Add(adres);
            await _context.SaveChangesAsync();

            return(result);
        }
예제 #5
0
        /// <summary>
        /// Get all menu contents
        /// </summary>
        /// <returns></returns>
        public List <Menu> GetMenu()
        {
            var menu = _context.Set <Menu>().ToList();

            return(menu);
        }
예제 #6
0
 public void Create(T entity)
 {
     _context.Set <T>().AddAsync(entity);
 }
예제 #7
0
        public GenericRepository(RestaurantDbContext restaurantDbContext)
        {
            _restaurantDbContext = restaurantDbContext;

            _entities = restaurantDbContext.Set <T>();
        }
예제 #8
0
 public Repository(RestaurantDbContext restaurant)
 {
     RestaurantDbContext = restaurant;
     _entities           = restaurant.Set <T>();
 }
예제 #9
0
 public bool AddItem(T item)
 {
     _context.Set <T>().Add(item);
     return(SaveChanges());
 }