예제 #1
0
 public ActionResult SaveFile(File file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var filetmp = _listFiles.Where(p => p.ID == file.FileID).FirstOrDefault();
             if (filetmp != null)
             {
                 _listSelectedFiles.Add(new File {
                     Name = filetmp.Name, Type = filetmp.Type, Contents = filetmp.Contents, DocumentTypeID = file.DocumentTypeID, EmployeeID = file.EmployeeID
                 });
             }
             else
             {
                 return(Json(new { warning = "file not found" }));
             }
         }
         else
         {
             return(Json(new { warning = "model is not valid" }));
         }
     }
     catch (Exception e)
     {
         ModelState.AddModelError("", e.Message);
         return(View(file));
     }
     return(PartialView("Partial_Views/_FilesSelected", _listSelectedFiles));
 }
예제 #2
0
        public ActionResult SaveFile(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            File file    = new File();
            var  filetmp = _listFiles.Where(p => p.ID == id).FirstOrDefault();

            if (filetmp != null)
            {
                file.FileID = filetmp.ID;
                file.Name   = filetmp.Name;
                file.Type   = filetmp.Type;
            }

            ViewBag.DocumentTypeID = new SelectList(_unitOfWork.DocumentTypeRepository.Get(), "DocumentTypeID", "Name", file?.DocumentTypeID);
            return(PartialView("Partial_Views/_FilesSaved", file));
        }