public ActionResult DeleteConfirmed(int id)
        {
            EnclosedDocument enclosedDocument = db.EnclosedDocuments.Find(id);

            db.EnclosedDocuments.Remove(enclosedDocument);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: EnclosedDocuments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EnclosedDocument enclosedDocument = db.EnclosedDocuments.Find(id);

            if (enclosedDocument == null)
            {
                return(HttpNotFound());
            }
            return(View(enclosedDocument));
        }
        public ActionResult Edit(DocumentsViewModel documentsViewModel)
        {
            if (ModelState.IsValid)
            {
                EnclosedDocument enclosedDocument = db.EnclosedDocuments.Find(documentsViewModel.Id);
                enclosedDocument.ApplicationId = UserHelper.GetUserId(db.Users, User.Identity);
                enclosedDocument.DocumentType  = documentsViewModel.DocumentType;
                enclosedDocument.Name          = documentsViewModel.Name;
                if (documentsViewModel.DocumentFile != null)
                {
                    enclosedDocument.DocumentFile = ImageConverter.ByteArrayFromPostedFile(documentsViewModel.DocumentFile);
                }
                db.Entry(enclosedDocument).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ApplicationId = new SelectList(db.Applications, "ApplicationId", "ApplicationId", documentsViewModel.ApplicationId);
            return(View(documentsViewModel));
        }
        // GET: EnclosedDocuments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EnclosedDocument   enclosedDocument   = db.EnclosedDocuments.Find(id);
            DocumentsViewModel enclosedDocumentVM = new DocumentsViewModel();

            enclosedDocumentVM.ApplicationId = enclosedDocument.ApplicationId;
            enclosedDocumentVM.DocumentType  = enclosedDocument.DocumentType;
            enclosedDocumentVM.Name          = enclosedDocument.Name;
            if (enclosedDocument.DocumentFile != null)
            {
                enclosedDocumentVM.DocumentFileDB = enclosedDocument.DocumentFile;
            }

            if (enclosedDocumentVM == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ApplicationId = new SelectList(db.Applications, "ApplicationId", "ApplicationId", enclosedDocumentVM.ApplicationId);
            return(View(enclosedDocumentVM));
        }