public async Task <UserCocktail> UpdateUserCocktail(UserCocktail updatedUserCocktail, int id) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var model = await _userCocktailsService.Update(updatedUserCocktail, id, userId); return(model); }
public async Task <UserCocktail> AddNewUserCocktail(UserCocktail newUserCocktail) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; newUserCocktail.UserId = userId; var model = await _userCocktailsService.AddNew(newUserCocktail); return(model); }
public bool AddToPreferences(int id) { Cocktail cocktail = _context.Cocktails.Find(id); UserCocktail userCocktail = new UserCocktail { User = _user, Cocktail = cocktail }; _context.UserCocktails.Add(userCocktail); _user.SavedCocktails.Add(userCocktail); return(_context.SaveChanges() == 1); }
public async Task FavoriteCocktailAsync(int userId, int cocktailId) { var user = await FindUserByIdAsync(userId); var cocktail = await cService.FindCocktailByIdAsync(cocktailId); var userCocktail = new UserCocktail() { UserId = userId, CocktailId = cocktailId, User = user, Cocktail = cocktail, UserUserName = user.UserName, CocktailName = cocktail.Name }; dbContext.UserCocktail.Add(userCocktail); await dbContext.SaveChangesAsync(); }
public async Task <int> DeleteUserCocktail(UserCocktail userCocktail) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; return(await _userCocktailsService.Delete(userCocktail, userId)); }