Esempio n. 1
0
        public OrderTypes GetOrderTypesFor(string userId, BuySellDocumentTypeENUM buySellDocumentTypeEnum, DateTime fromDate, DateTime toDate)
        {
            OrderTypes orderType = new OrderTypes();

            orderType.InProccess = GetMoneyCountItemFor(userId, BuySellDocStateENUM.InProccess, buySellDocumentTypeEnum, fromDate, toDate);
            //orderType.BackOrdered = GetMoneyCountItemFor(userId, BuySellDocStateENUM.BackOrdered, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.All = GetMoneyCountItemFor(userId, BuySellDocStateENUM.All, buySellDocumentTypeEnum, fromDate, toDate);

            orderType.RequestUnconfirmed = GetMoneyCountItemFor(userId, BuySellDocStateENUM.RequestUnconfirmed, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.RequestConfirmed   = GetMoneyCountItemFor(userId, BuySellDocStateENUM.RequestConfirmed, buySellDocumentTypeEnum, fromDate, toDate);

            orderType.BeingPreparedForShipmentBySeller = GetMoneyCountItemFor(userId, BuySellDocStateENUM.BeingPreparedForShipmentBySeller, buySellDocumentTypeEnum, fromDate, toDate);

            orderType.ReadyForPickup = GetMoneyCountItemFor(userId, BuySellDocStateENUM.ReadyForPickup, buySellDocumentTypeEnum, fromDate, toDate);



            orderType.CourierAcceptedByBuyerAndSeller = GetMoneyCountItemFor(userId, BuySellDocStateENUM.CourierAcceptedByBuyerAndSeller, buySellDocumentTypeEnum, fromDate, toDate);
            //todo
            //orderType.Cou= GetMoneyCountItemFor(userId, BuySellDocStateENUM.CourierComingToPickUp, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.CourierComingToPickUp = GetMoneyCountItemFor(userId, BuySellDocStateENUM.CourierComingToPickUp, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.PickedUp  = GetMoneyCountItemFor(userId, BuySellDocStateENUM.PickedUp, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.Enroute   = GetMoneyCountItemFor(userId, BuySellDocStateENUM.Enroute, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.Delivered = GetMoneyCountItemFor(userId, BuySellDocStateENUM.Delivered, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.Rejected  = GetMoneyCountItemFor(userId, BuySellDocStateENUM.Rejected, buySellDocumentTypeEnum, fromDate, toDate);
            orderType.Problem   = GetMoneyCountItemFor(userId, BuySellDocStateENUM.Problem, buySellDocumentTypeEnum, fromDate, toDate);

            return(orderType);
        }
Esempio n. 2
0
        //public void CancelRejectOrder(RejectCancelDeleteInbetweenClass rcdbc)
        //{

        //    rcdbc.BuySellDocId.IsNullOrWhiteSpaceThrowArgumentException();

        //    BuySellDoc buySellDoc = Find(rcdbc.BuySellDocId);
        //    buySellDoc.BuySellDocStateModifierEnum = rcdbc.BuySellDocStateModifierEnum;
        //    buySellDoc.BuySellDocumentTypeEnum = rcdbc.BuySellDocumentTypeEnum;


        //    //create subject
        //    rcdbc.Subject = rcdbc.ToString();

        //    if (rcdbc.Comment.IsNullOrWhiteSpace())
        //    { }
        //    else
        //    {
        //        //add the message
        //        //current user is sending the message.
        //        //if the document type is purchase, then it is the customer
        //        //if document type is sale, then it is the owner sending the message.
        //        //we need to find the persons for each.
        //        createMessage(rcdbc, buySellDoc);
        //    }

        //    createPenaltyTrx(buySellDoc);
        //    UpdateAndSave(buySellDoc);

        //}

        //private void createPenaltyTrx(BuySellDoc buySellDoc)
        //{
        //    if (buySellDoc.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Cancel)
        //    {
        //        IPenaltyClass penelty = PenaltyController.GetPenalty(buySellDoc);
        //        if (penelty.IsNull())
        //            return;
        //        //create a cash transaction

        //    }

        //}

        //private void createMessage(RejectCancelDeleteInbetweenClass rcdbc, BuySellDoc buySellDoc)
        //{
        //    string fromPersonId = "";
        //    string toPersonId = "";
        //    Person fromPerson = null;
        //    List<string> listOfToPeople = new List<string>();

        //    string buySellDocId = buySellDoc.Id;
        //    Person ownerPerson = OwnerBiz.GetPersonForPlayer(buySellDoc.OwnerId);
        //    Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId);

        //    ownerPerson.IsNullThrowException();
        //    customerPerson.IsNullThrowException();
        //    switch (buySellDoc.BuySellDocumentTypeEnum)
        //    {
        //        case BuySellDocumentTypeENUM.Sale:
        //            fromPersonId = ownerPerson.Id;
        //            fromPerson = ownerPerson;
        //            toPersonId = customerPerson.Id;
        //            listOfToPeople.Add(toPersonId);
        //            break;

        //        case BuySellDocumentTypeENUM.Purchase:
        //            toPersonId = ownerPerson.Id;
        //            fromPersonId = customerPerson.Id;
        //            fromPerson = customerPerson;
        //            listOfToPeople.Add(toPersonId);

        //            break;
        //        case BuySellDocumentTypeENUM.Delivery:
        //            Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(buySellDoc.DeliverymanId);
        //            deliveryPerson.IsNullThrowException();

        //            fromPersonId = deliveryPerson.Id;
        //            fromPerson = deliveryPerson;
        //            listOfToPeople.Add(ownerPerson.Id);
        //            listOfToPeople.Add(customerPerson.Id);
        //            break;

        //        case BuySellDocumentTypeENUM.Unknown:
        //        default:
        //            throw new Exception("Unknown document type");
        //    }

        //    Message message = new Message(
        //        fromPersonId,
        //        fromPerson,
        //        listOfToPeople,
        //        rcdbc.Subject,
        //        rcdbc.Comment,
        //        MessageENUM.Free,
        //        null);

        //    if (buySellDoc.Messages.IsNull())
        //        buySellDoc.Messages = new List<Message>();

        //    buySellDoc.Messages.Add(message);
        //    message.BuySellDocId = buySellDoc.Id;

        //    message.ListOfToPeopleId.IsNullOrEmptyThrowException();
        //    foreach (var pplId in message.ListOfToPeopleId)
        //    {
        //        Person person = PersonBiz.Find(pplId);
        //        person.IsNullThrowException();

        //        PeopleMessage pplMsg = new PeopleMessage();
        //        pplMsg.IsNullThrowException();
        //        pplMsg.PersonId = pplId;
        //        pplMsg.Person = person;
        //        pplMsg.MessageId = message.Id;
        //        PeopleMessageBiz.Create(pplMsg);

        //    }
        //    MessageBiz.Create(message);
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="buySellDocId"></param>
        /// <param name="buySellDocumentTypeEnum"></param>
        public void CancelDeliveryManAndSave_GET(string buySellDocId, BuySellDocumentTypeENUM buySellDocumentTypeEnum)
        {
            //clear the buySell header
            buySellDocId.IsNullOrWhiteSpaceThrowException();

            BuySellDoc buySellDoc = Find(buySellDocId);

            buySellDoc.IsNullThrowException();

            buySellDoc.BuySellDocumentTypeEnum     = buySellDocumentTypeEnum;
            buySellDoc.BuySellDocStateModifierEnum = BuySellDocStateModifierENUM.Cancel;

            Update(buySellDoc);
            SaveChanges();
            //mark the order as false. It should already be false
        }
Esempio n. 3
0
        public void RejectOrder_Code(string id, BuySellDocumentTypeENUM buySellDocumentTypeEnum, GlobalObject globalObject)
        {
            id.IsNullOrWhiteSpaceThrowException();
            //returnUrl.IsNullOrWhiteSpaceThrowException();

            BuySellDoc buySellDoc = Find(id);

            buySellDoc.IsNullThrowException();
            buySellDoc.BuySellDocStateEnum = BuySellDocStateENUM.Rejected;

            ControllerCreateEditParameter param = new ControllerCreateEditParameter();

            param.Entity       = buySellDoc as ICommonWithId;
            param.GlobalObject = globalObject;

            UpdateAndSave(param);
        }
Esempio n. 4
0
        public void AcceptCourier(FreightOfferTrx frtTrx, BuySellDocumentTypeENUM buySellDocumentTypeEnum, decimal currBalance, decimal insuranceRequired)
        {
            if (insuranceRequired < 0)
            {
                throw new Exception("Insurance cannot be less than zero!");
            }

            BuySellDoc bsd = getBuySellDoc(frtTrx);

            bsd.IsNullThrowException();
            exceptionSellerAndDeliveryManIsTheSame(frtTrx, bsd);

            bsd.BuySellDocumentTypeEnum = buySellDocumentTypeEnum;

            //this should all happen when courier accepts.
            //bsd.DeliveryCode_Customer = GetRandomCode();
            //bsd.PickupCode_Deliveryman = GetRandomCode();
            //bsd.FreightOfferTrxAcceptedId = frtTrx.Id;

            bsd.BuySellDocStateModifierEnum = BuySellDocStateModifierENUM.Accept;
            bsd.InsuranceRequired           = insuranceRequired;
            decimal maxDeliverymanLiability = maxPossibleLiabilityToDeliverParcel(bsd, frtTrx);

            if (frtTrx.MaxPossibleLiabilityToDeliverParcel() > currBalance)
            {
                frtTrx.IsNullThrowException();
                decimal insuranceAmountRqrdToPass = currBalance - frtTrx.OfferAmount;
                string  err = string.Format("The deliveryman '{0}' is unable to satisfy financial guarantee requirements by Rs{1:N0}. If you would still like to use him, you have an insurance amount of {2:N0} which can be reduced to {4:N0} which will allow you to proceed and accept the deliveryman. This is risky. If something goes wrong during delivery, then the maximum amount you will be able to recover from the deliveryman will be {3:N0}. Alternatively, you can request '{0}' to increase his guarantee amount with the Company. Proceed cautiously.",
                                            frtTrx.Deliveryman.FullName(),
                                            maxDeliverymanLiability - currBalance,
                                            bsd.InsuranceRequired,
                                            currBalance,
                                            insuranceAmountRqrdToPass);
                throw new Exception(err);
            }
            frtTrx.OfferAcceptedByOwner.SetToTodaysDate(UserName, UserId);
            FreightOfferTrxBiz.Update(frtTrx);
            Update(bsd);
        }
Esempio n. 5
0
        /// <summary>
        /// This gets a list from getAllDocuments_For.
        /// </summary>
        /// <param name="orderListDateDelimitedByDocumentTypeAndState"></param>
        /// <returns></returns>
        decimal get_Money_For(List <BuySellDoc> orderListDateDelimitedByDocumentTypeAndState, BuySellDocumentTypeENUM buySellDocumentTypeEnum)
        {
            //get all purchase orders for Owner

            //add up the purchase amoung
            if (orderListDateDelimitedByDocumentTypeAndState.IsNullOrEmpty())
            {
                return(0);
            }

            //The deliveryman is only counted once selected.
            if (buySellDocumentTypeEnum == BuySellDocumentTypeENUM.Delivery)
            {
                Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId);
                if (deliveryman.IsNull())
                {
                    return(0);
                }
            }

            decimal ttlOrdered = orderListDateDelimitedByDocumentTypeAndState.Sum(x => x.TotalOrdered);

            //foreach (var item in orderListDateDelimitedByDocumentTypeAndState)
            //{
            //    ttlOrdered += item.TotalOrdered;
            //}

            return(ttlOrdered);
        }
Esempio n. 6
0
        MoneyCountItemClass GetMoneyCountItemFor(string userId, BuySellDocStateENUM buySellDocStateEnum, BuySellDocumentTypeENUM buySellDocumentTypeEnum, DateTime fromDate, DateTime toDate)
        {
            List <BuySellDoc> alldocuments = getBuySellDocs_For(userId, buySellDocStateEnum, buySellDocumentTypeEnum, fromDate, toDate);

            MoneyCountItemClass mcic = new MoneyCountItemClass();

            mcic.MoneyAmount = get_Money_For(alldocuments, buySellDocumentTypeEnum);
            mcic.Count       = get_Count_For(alldocuments, buySellDocumentTypeEnum, buySellDocStateEnum);

            if (userId.IsNullOrWhiteSpace())
            {
                mcic.MenuName    = BuySellDoc.GetMenuItem_Admin(buySellDocStateEnum, buySellDocumentTypeEnum, mcic.MoneyAmount_Formatted, mcic.Count_Formatted);
                mcic.MenuToolTip = BuySellDoc.GetMenuToolTip_Admin(buySellDocStateEnum, buySellDocumentTypeEnum, mcic.MoneyAmount_Formatted, mcic.Count_Formatted);
            }
            else
            {
                //this is for the individual user
                mcic.MenuName    = BuySellDoc.GetMenuItem(buySellDocStateEnum, buySellDocumentTypeEnum, mcic.MoneyAmount_Formatted, mcic.Count_Formatted);
                mcic.MenuToolTip = BuySellDoc.GetMenuToolTip(buySellDocStateEnum, buySellDocumentTypeEnum, mcic.MoneyAmount_Formatted, mcic.Count_Formatted);
            }
            return(mcic);
        }
Esempio n. 7
0
        IQueryable <BuySellDoc> getByDocumentType_For(string userId, IQueryable <BuySellDoc> iq_allOrders, BuySellDocumentTypeENUM buySellDocumentTypeEnum)
        {
            //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in.");


            switch (buySellDocumentTypeEnum)
            {
            case BuySellDocumentTypeENUM.Sale:
            {
                try
                {
                    //all orders are returned because this is the admin
                    //if (userId.IsNullOrWhiteSpace())
                    //    return iq_allOrders;
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, ""));
                    }

                    Owner owner = OwnerBiz.GetPlayerFor(userId);
                    owner.IsNullThrowException("No Owner");
                    return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, owner.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting sales.", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Purchase:
            {
                try
                {
                    //all orders are returned because this is the admin
                    //if (userId.IsNullOrWhiteSpace())
                    //    return iq_allOrders;
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, ""));
                    }

                    Customer customer = CustomerBiz.GetPlayerFor(userId);
                    customer.IsNullThrowException("Customer");
                    return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, customer.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Delivery:
            {
                try
                {
                    //all orders are returned because this is the admin
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, ""));
                    }


                    Deliveryman deliveryMan = DeliverymanBiz.GetPlayerFor(userId);
                    deliveryMan.IsNullThrowException("deliveryMan");

                    return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, deliveryMan.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Salesman:
            {
                try
                {
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, ""));
                    }

                    Salesman salesman = SalesmanBiz.GetPlayerFor(userId);
                    salesman.IsNullThrowException("Salesman");

                    return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, salesman.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Unknown:
            default:
                throw new Exception("Unknown document type");
            }
        }
Esempio n. 8
0
        /// <summary>
        /// This is the one that returns a list of a sale or purchase documents for a specific state within a date period. This is the one that joins the operations.
        /// We will use this data to get the money amount and counts
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="buySellDocStateEnum"></param>
        /// <param name="buySellDocumentTypeEnum"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns></returns>
        List <BuySellDoc> getBuySellDocs_For(string userId, BuySellDocStateENUM buySellDocStateEnum, BuySellDocumentTypeENUM buySellDocumentTypeEnum, DateTime fromDate, DateTime toDate)
        {
            IQueryable <BuySellDoc> allDocsWithinDate      = FindAll().Where(x => x.MetaData.Created.Date >= fromDate && x.MetaData.Created.Date <= toDate);
            List <BuySellDoc>       allDocsWithinDateDEBUG = allDocsWithinDate.ToList();

            IQueryable <BuySellDoc> allDocsOfDocumentType      = getByDocumentType_For(userId, allDocsWithinDate, buySellDocumentTypeEnum);
            List <BuySellDoc>       allDocsOfDocumentTypeDEBUG = getByDocumentType_For(userId, allDocsWithinDate, buySellDocumentTypeEnum).ToList();

            IQueryable <BuySellDoc> IQueryable_allDocsOfDocState = BuySellDoc.IQuerable_Orders_For(buySellDocStateEnum, allDocsOfDocumentType);

            List <BuySellDoc> allFilteredDocs = IQueryable_allDocsOfDocState.ToList();

            //fill in the Complex Addresses
            if (!allFilteredDocs.IsNullOrEmpty())
            {
                foreach (BuySellDoc buysellDoc in allFilteredDocs)
                {
                    loadAddressShipTo(buysellDoc);
                    loadAddressBillTo(buysellDoc);
                    loadAddressShipFrom(buysellDoc);

                    //this changes the value of the doc.
                    //buysellDoc.BuySellDocumentTypeEnum = buySellDocumentTypeEnum;
                }
            }

            return(allFilteredDocs);
        }
Esempio n. 9
0
        //public BuySellStatementModel GetDeliveryOrders(string userId, string id)
        //{
        //    userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in.");

        //    List<BuySellDoc> lstbuySellDocs = new List<BuySellDoc>(); ;

        //    BuySellDoc buySellDoc = Find(id);
        //    buySellDoc.IsNullThrowException();

        //    lstbuySellDocs.Add(buySellDoc);

        //    decimal customerBalanceRefundable = 0;
        //    decimal customerBalanceNonRefundable = 0;

        //    BuySellStatementModel buySellStatementModel = new BuySellStatementModel(lstbuySellDocs, DateTime.MinValue, DateTime.MaxValue, BuySellDocumentTypeENUM.Delivery, false, customerBalanceRefundable, customerBalanceNonRefundable, BuySellDocStateENUM.ReadyForPickup);

        //    return buySellStatementModel;

        //}


        /// <summary>
        /// This gets the order list of Sale or Purchase documents date delimited.
        /// This also figures out if it is a sale or a purchase
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="buySellDocumentTypeEnum"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns></returns>

        public BuySellStatementModel GetBuySellStatementModel(string userId, DateTime fromDate, DateTime toDate, bool isAdmin, BuySellDocumentTypeENUM buySellDocumentTypeEnum, BuySellDocStateENUM buySellDocStateEnum)
        {
            //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in.");


            List <BuySellDoc> buySellDocs = getBuySellDocs_For(userId, buySellDocStateEnum, buySellDocumentTypeEnum, fromDate, toDate).ToList();

            decimal     customerBalanceRefundable = 0, customerBalanceNonRefundable = 0;
            Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(userId);



            BuySellStatementModel buySellStatementModel = new BuySellStatementModel(buySellDocs, fromDate, toDate, buySellDocumentTypeEnum, isAdmin, customerBalanceRefundable, customerBalanceNonRefundable, deliveryman, buySellDocStateEnum);

            return(buySellStatementModel);
        }
Esempio n. 10
0
        /// <summary>
        /// This gets a list from getAllDocuments_For.
        /// </summary>
        /// <param name="orderListDateDelimitedByDocumentTypeAndState"></param>
        /// <returns></returns>
        long get_Count_For(List <BuySellDoc> orderListDateDelimitedByDocumentTypeAndState, BuySellDocumentTypeENUM buySellDocumentTypeEnum, BuySellDocStateENUM buySellDocStateEnum)
        {
            //get all purchase orders for Owner

            //add up the purchase amoung
            if (orderListDateDelimitedByDocumentTypeAndState.IsNullOrEmpty())
            {
                return(0);
            }


            IQueryable <BuySellDoc> iq_orderListDateDelimitedByDocumentTypeAndState = orderListDateDelimitedByDocumentTypeAndState.AsQueryable <BuySellDoc>();

            IQueryable <BuySellDoc> orderListDuplicate = BuySellDoc.IQuerable_Orders_For(
                buySellDocStateEnum,
                iq_orderListDateDelimitedByDocumentTypeAndState);

            long count = 0;

            //if (buySellDocumentTypeEnum == BuySellDocumentTypeENUM.Delivery)
            //{
            //    if (buySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup || buySellDocStateEnum == BuySellDocStateENUM.All)
            //    { }
            //    else
            //    {
            //        Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId);

            //        if (deliveryman.IsNull())
            //            return 0;

            //        count = orderListDuplicate
            //            .Where(x => x.DeliverymanId == deliveryman.Id)
            //            .Count();

            //        return count;
            //    }
            //}
            //for the deliveryman, it should return all items as per its query
            count = orderListDuplicate.Count();
            return(count);
        }
Esempio n. 11
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);
        }