public async System.Threading.Tasks.Task <T> Add(T entity) { _ctx.Set <T>().Add(entity); await _ctx.SaveChangesAsync(); return(entity); }
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)); }
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); }
/// <summary> /// Get all menu contents /// </summary> /// <returns></returns> public List <Menu> GetMenu() { var menu = _context.Set <Menu>().ToList(); return(menu); }
public void Create(T entity) { _context.Set <T>().AddAsync(entity); }
public GenericRepository(RestaurantDbContext restaurantDbContext) { _restaurantDbContext = restaurantDbContext; _entities = restaurantDbContext.Set <T>(); }
public Repository(RestaurantDbContext restaurant) { RestaurantDbContext = restaurant; _entities = restaurant.Set <T>(); }
public bool AddItem(T item) { _context.Set <T>().Add(item); return(SaveChanges()); }