public ActionResult AttachDocument(int DocId, int DocTypeId)
        {
            List <DocumentAttachmentViewModel> vm = new List <DocumentAttachmentViewModel>();
            var Attachments = (from p in db.DocumentAttachment.AsNoTracking()
                               where p.DocId == DocId && p.DocTypeId == p.DocTypeId
                               select p).ToList();

            if (Attachments.Count() > 0)
            {
                foreach (var item in Attachments)
                {
                    DocumentAttachmentViewModel dm = new DocumentAttachmentViewModel();
                    dm.DocId                = item.DocId;
                    dm.DocTypeId            = item.DocTypeId;
                    dm.DocumentAttachmentId = item.DocumentAttachmentId;
                    dm.FileFolderName       = item.FileFolderName;
                    dm.FileName             = item.FileName;
                    dm.SetExtension();
                    vm.Add(dm);
                }
            }
            else
            {
                vm.Add(new DocumentAttachmentViewModel
                {
                    DocId     = DocId,
                    DocTypeId = DocTypeId,
                });
            }

            return(PartialView("~/Views/Shared/_DocumentAttachment.cshtml", vm));
        }
        public ActionResult AttachDocument(DocumentAttachmentViewModel vm)
        {
            if (Request.Files[0] != null && Request.Files[0].ContentLength > 0)
            {
                UploadDocument ud        = new UploadDocument();
                string         FileNames = "";
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    string FileName   = "";
                    string FolderName = "";

                    ud.UploadFile(i, new Dictionary <string, string>(), vm.DocTypeId + "_" + vm.DocId, Constants.FileTypeConstants.Other, out FolderName, out FileName);

                    DocumentAttachment da = new DocumentAttachment();

                    da.DocId          = vm.DocId;
                    da.DocTypeId      = vm.DocTypeId;
                    da.FileFolderName = FolderName;
                    da.FileName       = FileName;
                    da.CreatedBy      = User.Identity.Name;
                    da.CreatedDate    = DateTime.Now;
                    da.ModifiedBy     = User.Identity.Name;
                    da.ModifiedDate   = DateTime.Now;
                    da.ObjectState    = Model.ObjectState.Added;
                    db.DocumentAttachment.Add(da);

                    FileNames += da.FileName + ", ";
                }

                db.SaveChanges();

                //LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                //{
                //    DocTypeId = vm.DocTypeId,
                //    DocId = vm.DocId,
                //    ActivityType = (int)ActivityTypeContants.FileAdded,
                //    DocNo = FileNames,
                //}));
            }

            return(RedirectToAction("AttachDocument", new { DocId = vm.DocId, DocTypeId = vm.DocTypeId }));
        }
 protected AttachmentPanelDecoratorBase_NonGeneric DocumentDecoratorTransform(AttachmentModelBase documentModel)
 {
     return(new DocumentPanelDecorator(DocumentAttachmentViewModel.CreateEditable((DocumentAttachmentModel)documentModel)));
 }