Exemplo n.º 1
0
        public async Task SetFavorite(EditFavoriteModel model)
        {
            var customer = dbContext.Customers.SingleOrDefault(c => c.LoyaltyNumber == model.LoyaltyNumber);

            customer.FavoriteDrink = model.Favorite;
            await dbContext.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task SetFavorite(EditFavoriteModel model)
        {
            var customers = dbContext.Customers.FromSqlRaw("SELECT * FROM Customers where LoyaltyNumber = " + model.LoyaltyNumber.ToString());
            var customer  = await customers.FirstOrDefaultAsync();

            customer.FavoriteDrink = model.Favorite;
            await dbContext.SaveChangesAsync();
        }
        public async Task <IActionResult> EditFavorite(EditFavoriteModel model)
        {
            await repo.SetFavorite(model);

            return(RedirectToAction("LoyaltyOverview", new { loyaltyNumber = model.LoyaltyNumber }));
        }