Exemplo n.º 1
0
        private void addOwner(Product p)
        {
            if (IsCreate)
            {
                if (!UserId.IsNullOrWhiteSpace())
                {
                    //user is logged in
                    //make sure the user is an Owner

                    Owner owner = OwnerBiz.GetOwnerForUser(UserId);
                    if (!owner.IsNull())
                    {
                        //user is an owner
                        //Now this user will own this product.
                        p.OwnerId = owner.Id;

                        if (owner.Shops.IsNull())
                        {
                            owner.Shops = new List <Product>();
                        }
                        owner.Shops.Add(p);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override IList <ICommonWithId> GetListForIndex()
        {
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in");
            Owner owner = OwnerBiz.GetOwnerForUser(UserId);

            owner.IsNullThrowException("Owner not found.");

            IList <ProductChild> lst = FindAll().Where(x => x.OwnerId == owner.Id && x.Hide == IsShowHidden).ToList() as IList <ProductChild>;

            return(lst.Cast <ICommonWithId>().ToList());
        }
Exemplo n.º 3
0
        //public override async Task<IList<ICommonWithId>> GetListForIndexAsync(ControllerIndexParams parameters)
        //{
        //    IList<ProductChild> lst = await FindAllAsync();
        //    lst = lst.Where(x => x.Hide == IsDontShowHidden).ToList() as IList<ProductChild>;
        //    return lst.Cast<ICommonWithId>().ToList();
        //}
        public override async Task <IList <ICommonWithId> > GetListForIndexAsync(ControllerIndexParams parameters)
        {
            //var lstEntities = await FindAllAsync();
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in");
            Owner owner = OwnerBiz.GetOwnerForUser(UserId);

            owner.IsNullThrowException("Owner not found.");
            List <ProductChild> lstEntities;

            if (IsShowHidden)
            {
                lstEntities = await FindAll().Where(x => x.OwnerId == owner.Id && x.Hide == IsShowHidden).ToListAsync();
            }
            else
            {
                lstEntities = await FindAll().Where(x => x.OwnerId == owner.Id).ToListAsync();
            }
            IList <ICommonWithId> lstIcom = lstEntities.Cast <ICommonWithId>().ToList();

            return(lstIcom);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Every Owner can add only One product of a specific name.
        /// We need to load the product in this at a higher level because we are unable to access ProductBiz here
        /// </summary>
        /// <param name="parm"></param>
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in.");

            ProductChild pc = parm.Entity as ProductChild;

            pc.IsNullThrowException("Unable to unbox Product Child");

            //Product comes from the controller.
            pc.ProductId.IsNullOrWhiteSpaceThrowException("There is no parent Product");
            pc.Product.IsNullThrowException("Product Has not been loaded!");


            if (pc.Name.IsNullOrWhiteSpace())
            {
                pc.Name = pc.Product.Name;
            }

            //we need to load the owner in because the name is used to create
            //a directory for the uploads.
            //first get the Owners Id
            Owner owner = OwnerBiz.GetOwnerForUser(UserId);

            owner.IsNullThrowException("Owner not found!");
            pc.OwnerId = owner.Id;
            pc.Owner   = owner;

            ////I dont want to add the features. I will add them temporarily when it is being presented,
            ////addProductFeatures(pc);
            FixProductChildFeatures(pc);

            base.Fix(parm);

            //check the address. If the address is a new address, make it past of the database for the ProductChild Owner
            //check if the address exists

            AddShippingAddressToOwnerPersonIfItIsNew(pc);
            //AddPhoneNumberToOwnerPersonIfItsNew(pc);
        }