/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public void Delete(UnmarkFavoriteItem request) { var user = _userManager.GetUserById(request.UserId); var item = (Folder)DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); // Get the user data for this item var data = item.GetUserData(user, true); // Set favorite status data.IsFavorite = false; var task = _userManager.SaveUserDataForItem(user, item, data); Task.WaitAll(task); }
/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public void Delete(UnmarkFavoriteItem request) { var user = _userManager.GetUserById(request.UserId); var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var key = item.GetUserDataKey(); // Get the user data for this item var data = _userDataRepository.GetUserData(user.Id, key); // Set favorite status data.IsFavorite = false; var task = _userDataRepository.SaveUserData(user.Id, key, data, CancellationToken.None); Task.WaitAll(task); }
/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public object Delete(UnmarkFavoriteItem request) { var dto = MarkFavorite(request.UserId, request.Id, false); return(ToOptimizedResult(dto)); }