private static bool BundleInvalid(ShoppoingCartItemModel cartItemModel, IMyMentorRepository repository, StringsManager stringManager, string currentUserId, ref bool contentItemActive, ref bool canBeOrderedByTeacher, ref bool contentItemOwner, out Purchase existingPurchase, out ParseObject result)
        {
            Bundle bundle = Task.Run(() => repository.FindMinimalBundleById(cartItemModel.ContentItemId)).Result;

            existingPurchase = repository.FindPurchaseByContentIdAndUserId(cartItemModel.ContentItemId, currentUserId);
            contentItemActive = bundle.IsActive();
            canBeOrderedByTeacher = bundle.CanBeOrderedByTeacher(currentUserId);
            result = bundle;
            contentItemOwner = currentUserId == bundle.Teacher.ObjectId;

            if (existingPurchase == null)
            {
                return false;
            }

            if (existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.PackagePurchased ||
                existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.PackageIsActive)
            {
                if (existingPurchase.ClipKind == ClipPurchaseTypes.Bundle)
                {
                    cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.BundleAlreadyPurchased);
                }
                return true;
            }

            if (existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.DemoOrdered ||
                existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.DemoIsActive)
            {
                if (existingPurchase.ClipKind == ClipPurchaseTypes.Demo)
                {
                    cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.DemoAlreadyOrdered);
                }
                return true;
            }

            if (existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.PackageIsInBasket)
            {
                cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.BundleAlreadyInBasket);
                return true;
            }

            return false;
        }
        private static bool LessonInvalid(ShoppoingCartItemModel cartItemModel, IMyMentorRepository repository, 
            StringsManager stringManager, out Purchase existingPurchase, string currentUserId, 
            ref bool contentItemActive, ref bool canBeOrderedByTeacher, ref bool contentItemOwner, out ParseObject result)
        {
            Clip lesson = null;
            lesson = Task.Run(() => new ParseQuery<Clip>()
                .Include("status")
                .Include("currency")
                .GetAsync(cartItemModel.ContentItemId)).Result;

            existingPurchase = repository.FindPurchaseByContentIdAndUserId(lesson.ObjectId, currentUserId );
            contentItemActive = lesson.IsActive();
            canBeOrderedByTeacher = lesson.CanBeOrderedByTeacher(currentUserId);
            result = lesson;
            contentItemOwner = lesson.Teacher.ObjectId == currentUserId;

            if (existingPurchase == null)
            {
                return false;
            }

            if (existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.LessonPurchased ||
                existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.LessonIsActive)
            {
                if (existingPurchase.ClipKind == ClipPurchaseTypes.Lesson)
                {
                    cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.LessonAlreadyPurchased);
                }
                if (existingPurchase.ClipKind == ClipPurchaseTypes.Demo)
                {
                    cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.DemoAlreadyOrdered);
                }
                return true;
            }

            if (existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.DemoOrdered ||
                existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.DemoIsActive)
            {
                if (existingPurchase.ClipKind == ClipPurchaseTypes.Demo)
                {
                    cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.DemoAlreadyOrdered);
                }
                return true;
            }

            if (existingPurchase.PurchaseStatusCode == PurchaseStatusCodes.LessonIsInBaskert)
            {
                cartItemModel.ErrorMessage = stringManager.GetLocalizedString(Strings.LessonAlreadyInBasket);
                return true;
            }
            return false;
        }