Esempio n. 1
0
        private void getPicture(ProductChildInitializer item, ProductChild pc)
        {
            IHasUploads pcHasuploads = pc as IHasUploads;

            pc.IsNullThrowException(string.Format("Programming Error. Product Child is not showing as IHasUploads. It is. Currently initializing '{0}'", item.ProductName));

            string originalname        = item.ProductName.RemoveAllSpaces().ToString();
            string relative_SrcPath    = pc.MiscFilesLocation_Initialization();
            string relative_targetPath = pc.MiscFilesLocation(UserName);

            string filenameNoExtention = getFileNameWithoutExtention(relative_SrcPath, originalname);


            if (!imageFileExists(filenameNoExtention))
            {
                return;
            }

            #region Copy File
            string originalnameWithoutExtention = originalname;
            List <UploadedFile> uploadedFileLst = new List <UploadedFile>();

            //copy the actual file to the new spot. We need to do it here so we can get it's new name
            //== COPY FILE
            string newNameWithMappedPathPlusExtention = CopyFile(relative_SrcPath, relative_targetPath, Path.ChangeExtension(originalnameWithoutExtention, ExtentionFound));

            //create the upload file
            UploadedFile uf = new UploadedFile(
                originalnameWithoutExtention,
                Path.GetFileNameWithoutExtension(newNameWithMappedPathPlusExtention),
                ExtentionFound,
                relative_targetPath);

            //add to uploadlist
            uploadedFileLst.Add(uf);

            #endregion
            if (!uploadedFileLst.IsNullOrEmpty())
            {
                foreach (UploadedFile file in uploadedFileLst)
                {
                    file.MetaData.Created.SetToTodaysDate(UserName, UserId);


                    //initializes navigation if it is null

                    //You need to add a refrence here to save the file in the UploadedFile as well.
                    file.ProductChild   = pc;
                    file.ProductChildId = pc.Id;

                    if (pcHasuploads.MiscFiles.IsNull())
                    {
                        pcHasuploads.MiscFiles = new List <UploadedFile>(); //intializing
                    }
                    pcHasuploads.MiscFiles.Add(file);

                    UploadedFileBiz.Create(CreateControllerCreateEditParameter(file as ICommonWithId));
                }
            }
        }
Esempio n. 2
0
        private void getParent(ProductChildInitializer item, ProductChild pc)
        {
            //Get the parent;
            Product p = FindByName(item.ParentName);

            p.IsNullThrowException("Product Not found. Initialization Data error.");

            pc.Product   = p;
            pc.ProductId = p.Id;

            if (p.ProductChildren.IsNull())
            {
                p.ProductChildren = new List <ProductChild>();
            }

            p.ProductChildren.Add(pc);
        }
Esempio n. 3
0
        private void getUser(ProductChildInitializer item, ProductChild pc)
        {
            //   throw new NotImplementedException();

            ////get user
            //ApplicationUser user = UserBiz.FindAll().FirstOrDefault(x =>
            //    x.UserName.ToLower() == item.UserName.ToLower());

            //user.IsNullThrowException(string.Format("User '{0}' Not found. Erronious starting data.", item.UserName));

            //pc.User = user;
            //pc.UserId = user.Id;

            //if (user.ProductChildren.IsNull())
            //    user.ProductChildren = new List<ProductChild>();

            //user.ProductChildren.Add(pc);
        }