public FavouriteContent AddToFavourites(int nodeId, int userId) { var existing = this.GetFavourite(nodeId, userId); if (existing != null) return existing; var fc = new FavouriteContent { NodeId = nodeId, UserId = userId, SortOrder = 0 }; if (FavouriteContentValid(fc)) { _fcRepo.Save(fc); return fc; } return null; }
private bool FavouriteContentValid(FavouriteContent fc) { var node = Services.ContentService.GetById(fc.NodeId); // Check node exists if (node == null) return false; // Check not in the bin if (node.ParentId == Constants.System.RecycleBinContent) return false; // Check user exists return Services.UserService.GetUserById(fc.UserId) != null; }