public ActionResult UploadFile(Guid guid)
        {
            BL.FileUpload fuBL        = new BL.FileUpload();
            var           uploadFiles = UploadControlExtension.GetUploadedFiles("FileUploadControl", UploadHelper.CommonUploadValidationSettings, UploadHelper.FileUploadComplete).FirstOrDefault();

            string fileDesc = GetFileDescFromCookie(guid);


            if (uploadFiles.FileName != "")
            {
                var model = new VM.FileItem()
                {
                    FileGuid    = Guid.NewGuid(),
                    FileName    = uploadFiles.FileName,
                    FileSize    = uploadFiles.ContentLength,
                    FileContent = uploadFiles.FileBytes,
                    Description = fileDesc,
                    CreatedBy   = "sysAdmin",//UserHelper.GetCurrentUser().LogonName,
                    CreatedDate = DateTime.Now
                };

                fuBL.Save(model);
            }
            return(null);
        }
示例#2
0
        public VM.FileItem GetItemByGuid(Guid guid)
        {
            var entity = Ctx.tbl_Attachment.FirstOrDefault(t => t.AttachmentGuid == guid);

            if (entity != null)
            {
                var fileItem = new VM.FileItem();
                fileItem.FileName    = entity.FileName;
                fileItem.FileContent = entity.FileContent;
                return(fileItem);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        public void Save(VM.FileItem item)
        {
            var entity = new MD.tbl_Attachment()
            {
                AttachmentGuid = item.FileGuid,
                FileName       = item.FileName,
                FileContent    = item.FileContent,
                FileSize       = item.FileSize,
                Description    = item.Description,
                IsDeleted      = false,
                CreatedBy      = item.CreatedBy,
                CreatedDate    = item.CreatedDate
            };

            Ctx.tbl_Attachment.Add(entity);
            Ctx.SaveChanges();
        }