Exemplo n.º 1
0
        private LikeUnlikeParameters CountProductChildLikes(string productChildId, string personId)
        {
            var all = FindAll().Where(x => x.ProductChildId == productChildId);

            var likes   = all.Count(x => x.IsLike == true);
            var unlikes = all.Count(x => x.IsLike == false);

            bool hasLiked = !(all.FirstOrDefault(x => x.PersonId == personId && x.IsLike == true)).IsNull();

            bool hasUnliked = false;

            if (!hasLiked)
            {
                hasUnliked = !(all.FirstOrDefault(x => x.PersonId == personId && x.IsLike == false)).IsNull();
            }

            LikeUnlikeParameters param = new LikeUnlikeParameters(likes, unlikes, "productChildId");

            param.HasLiked   = hasLiked;
            param.HasUnLiked = hasUnliked;

            addUsersWhoLikeAndDidNotLike(all, param);

            return(param);
        }
Exemplo n.º 2
0
        private LikeUnlikeParameters countMenuPath1Likes(string menuPath1Id, string personId)
        {
            var all = FindAll().Where(x => x.MenuPath1Id == menuPath1Id);

            var likes   = all.Count(x => x.IsLike == true);
            var unlikes = all.Count(x => x.IsLike == false);

            bool hasLiked   = !(all.FirstOrDefault(x => x.PersonId == personId && x.IsLike == true)).IsNull();
            bool hasUnliked = !(all.FirstOrDefault(x => x.PersonId == personId && x.IsLike == false)).IsNull();

            LikeUnlikeParameters param = new LikeUnlikeParameters(likes, unlikes, "menuPath1Id");

            param.HasLiked   = hasLiked;
            param.HasUnLiked = hasUnliked;

            addUsersWhoLikeAndDidNotLike(all, param);
            return(param);
        }
Exemplo n.º 3
0
        public ProductChild LoadProductChildForLandingPage(string productChildId, string searchFor, string returnUrl)
        {
            //ProductChild productChild = _icrudBiz.Factory() as ProductChild;
            //productChildId.IsNullThrowExceptionArgument("Id not received. Bad Request");

            ProductChild productChild = Find(productChildId);

            productChild.IsNullThrowException("Product Child not found.");

            string productIdDud      = "";
            string isandForSearchDud = "";
            string selectIdDud       = "";
            string menuPathMainIdDud = "";
            string logoAddress       = "";
            string buttonDud         = "";
            //string sortByDud = "";
            LikeUnlikeParameters likeUnlikeParameters = null;

            bool isMenuDud   = false;
            bool isUserAdmin = false;
            BuySellDocumentTypeENUM buySellDocumentTypeEnum = BuySellDocumentTypeENUM.Unknown; //DUD
            BuySellDocStateENUM     BuySellDocStateEnum     = BuySellDocStateENUM.Unknown;     //dud

            if (!UserId.IsNullOrWhiteSpace())
            {
                isUserAdmin = UserBiz.IsAdmin(UserId);
            }

            ControllerIndexParams parms = new ControllerIndexParams(
                productChildId,
                menuPathMainIdDud,
                searchFor,
                isandForSearchDud,
                selectIdDud,
                MenuENUM.IndexMenuProductChildLandingPage,
                SortOrderENUM.Item1_Asc,
                logoAddress,
                productChild,
                productChild,
                UserId,
                UserName,
                isUserAdmin,
                isMenuDud,
                BreadCrumbManager,
                ActionNameENUM.Unknown,
                likeUnlikeParameters,
                productIdDud,
                returnUrl,
                buySellDocumentTypeEnum,
                BuySellDocStateEnum,
                buttonDud);

            InitializeMenuManagerForEntity(parms);

            //IHasUploads hasUploadsEntity = parms.Entity as IHasUploads;
            //MenuManager menuManager = new MenuManager(parms.Entity.MenuManager.MenuPathMain, null, null, parms.Menu.MenuEnum, BreadCrumbManager, parms.LikeUnlikeCounter, UserId, parms.ReturnUrl, UserName);
            IMenuManager menuManager = parms.Entity.MenuManager;

            if (menuManager.IndexMenuVariables.IsNull())
            {
                menuManager.IndexMenuVariables = new IndexMenuVariables(UserId);
            }



            Person person = UserBiz.GetPersonFor(UserId);

            if (!person.IsNull())
            {
                string userPersonId         = person.Id;
                string productChildPersonId = productChild.Owner.PersonId;
                menuManager.IndexMenuVariables.updateRequiredProperties(userPersonId, productChildPersonId);
            }



            List <string> pictureAddresses = GetCurrItemsPictureList(productChild);

            //if none are available get them from the product
            if (pictureAddresses.IsNullOrEmpty())
            {
                productChild.Product.IsNullThrowException();
                pictureAddresses = GetCurrItemsPictureList(productChild.Product);
            }

            if (pictureAddresses.IsNullOrEmpty())
            {
                pictureAddresses = GetDefaultPicture();
            }



            menuManager.PictureAddresses = pictureAddresses;

            ////also add the ProductChildperson and UserPerson
            //Person userPerson = UserBiz.GetPersonFor(UserId);

            //if (!productChild.Owner.IsNull())
            //    menuManager.IndexMenuVariables.ProductChildPersonId = productChild.Owner.PersonId;

            productChild.AllFeatures = Get_All_ProductChild_Features_For(productChild);



            if (UserId.IsNullOrEmpty())
            {
                //Log an annonymous user as a visitor
            }
            else
            {
                //Log user as visitor to this product child
                LogPersonsVisit(UserId, productChild);
            }


            return(productChild);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This will find the first count.
        /// The return list for the like/unlike is made in addUsersWhoLikeAndDidNotLike
        /// </summary>
        /// <param name="menuPath1Id"></param>
        /// <param name="menuPath2Id"></param>
        /// <param name="menuPath3Id"></param>
        /// <param name="productId"></param>
        /// <param name="productChildId"></param>
        /// <param name="userId"></param>
        /// <param name="isLike"></param>
        /// <returns></returns>
        public LikeUnlikeParameters Count(string menuPath1Id, string menuPath2Id, string menuPath3Id, string productId, string productChildId, string userId, bool oppositeWasDeleted)
        {
            //userId.IsNullOrWhiteSpaceThrowException("User is not logged in");

            string personId = "";
            LikeUnlikeParameters likeUnlikeParameter = new LikeUnlikeParameters(0, 0, "Count Default");

            if (!userId.IsNullOrWhiteSpace())
            {
                Person person = UserBiz.GetPersonFor(userId);
                person.IsNullThrowException("Person not found");
                personId = person.Id;
                personId.IsNullOrWhiteSpaceThrowException("personId");
            }


            if (!productChildId.IsNullOrWhiteSpace())
            {
                likeUnlikeParameter = CountProductChildLikes(productChildId, personId);
                //this is true if opposite was deleted and signals the Javascript to
                //reduce the oppoiste number by 1.
                likeUnlikeParameter.OppositeDeleted = oppositeWasDeleted;

                return(likeUnlikeParameter);
            }

            if (!productId.IsNullOrWhiteSpace())
            {
                likeUnlikeParameter = ProductLikes(productId, personId);
                //this is true if opposite was deleted and signals the Javascript to
                //reduce the oppoiste number by 1.
                likeUnlikeParameter.OppositeDeleted = oppositeWasDeleted;

                return(likeUnlikeParameter);
            }


            if (!menuPath3Id.IsNullOrWhiteSpace())
            {
                likeUnlikeParameter = CountMenuPath3Likes(menuPath3Id, personId);
                //this is true if opposite was deleted and signals the Javascript to
                //reduce the oppoiste number by 1.
                likeUnlikeParameter.OppositeDeleted = oppositeWasDeleted;

                return(likeUnlikeParameter);
            }


            if (!menuPath2Id.IsNullOrWhiteSpace())
            {
                likeUnlikeParameter = countMenuPath2Likes(menuPath2Id, personId);
                //this is true if opposite was deleted and signals the Javascript to
                //reduce the oppoiste number by 1.
                likeUnlikeParameter.OppositeDeleted = oppositeWasDeleted;

                return(likeUnlikeParameter);
            }

            if (!menuPath1Id.IsNullOrWhiteSpace())
            {
                likeUnlikeParameter = countMenuPath1Likes(menuPath1Id, personId);;
            }

            //this is true if opposite was deleted and signals the Javascript to
            //reduce the oppoiste number by 1.
            likeUnlikeParameter.OppositeDeleted = oppositeWasDeleted;

            return(likeUnlikeParameter);
        }
Exemplo n.º 5
0
        private static void addUsersWhoLikeAndDidNotLike(IQueryable <LikeUnlike> all, LikeUnlikeParameters param)
        {
            var listOfLikeUsers = all
                                  .Where(x => x.IsLike == true)
                                  .ToList()
                                  .Select(x => new ParticipatingPeople(x.PersonId, x.Person.FullName(), @"\Content\MyImages\BlankImage.jpg", x.Comment, x.MetaData.Created.Date ?? DateTime.MaxValue))
                                  .Distinct <ParticipatingPeople>()
                                  .ToList();

            var listOfUsersWhoDidNotLike = all
                                           .Where(x => x.IsLike == false)
                                           .ToList()
                                           .Select(x => new ParticipatingPeople(x.PersonId, x.Person.FullName(), @"\Content\MyImages\BlankImage.jpg", x.Comment, x.MetaData.Created.Date ?? DateTime.MaxValue))
                                           .Distinct <ParticipatingPeople>()
                                           .ToList();

            param.PeopleWhoLikedThis       = listOfLikeUsers;
            param.PeopleWhoDidNotLikedThis = listOfUsersWhoDidNotLike;
        }