コード例 #1
0
 public ActionResult UploadDocument()
 {
     if (Session["RecordID"] != null)
     {
         int _recordID = 0;
         string mediaDocument;
         //Gather the Info
         _recordID = Convert.ToInt32(Session["RecordID"].ToString());
         mediaDocument = Request.Files["mediaDocument"].FileName;
         //Get the Info from the Repository
         Cascade.Data.Repositories.MSIMediaFormRepository repository = new MSIMediaFormRepository();
         Cascade.Data.Models.MSI_MediaForm _mediaForm = (from existingForm in repository.GetAll().Where(record => record.ID == _recordID)
                                                         select existingForm).First();
         if (!string.IsNullOrEmpty(mediaDocument))
         {
             string additionalIdentifier = Guid.NewGuid().ToString();
             //User the additional Identifier to uniquely Identify filename
             fileProcessor.SaveUploadedFileWithIdentifier(Request.Files["mediaDocument"], additionalIdentifier);
             _mediaForm.FileName = additionalIdentifier + "_" + mediaDocument;
             repository.Update(_mediaForm);
         }
         //Redirect to View Edit Form
         return RedirectToAction("Details", "Media", new { id = _mediaForm.ID });
     }
     else
     {
         //Something is wrong so go to main page
         return RedirectToAction("Index", "Media");
     }
 }
コード例 #2
0
 public JsonResult GetMediaData(int id)
 {
     MSIMediaFormRepository portMediaRepo = new MSIMediaFormRepository();
     var _portMediaData = from _portMedia in portMediaRepo.GetAll().Distinct()
                          where _portMedia.ID == id
                          select _portMedia;
     return Json(_portMediaData.SingleOrDefault(), JsonRequestBehavior.AllowGet);
 }