public ActionResult AddDocument(FormCollection collection)
{
try
{
IDocumentsRepository docs = new DocumentsRepository();
string _SourceID = collection["SourceID"];
string _SourceType = collection["SourceType"];
string _ReviewID = collection["ReviewID"];
string _PALibID = collection["PALibID"];
string _contributor = collection["CONTRIBUTOR"];
collection["UserID"] = 1.ToString();
collection["docfiletype"] = collection["docfileadd"];
if (collection["docfileadd"].ToString().Equals("upload"))
{
foreach (string filename in Request.Files)
{
HttpPostedFileBase file = Request.Files[filename];
var document_dir = ConfigurationManager.AppSettings["@BaseDir"];
var file_path = Request.PhysicalApplicationPath + document_dir;
if (file.ContentLength > 0)
{
string filePath = Path.Combine(file_path, Path.GetFileName(file.FileName));
file.SaveAs(filePath);
collection["DocName"] = file.FileName;
collection["DocPath"] = file_path;
collection["DocAccess"] = collection["ddDocumentTypeEdit"];
int documentID = UpdateUtils.InsertDocuments(collection, int.Parse(_SourceID),
int.Parse(_SourceType));
UpdateUtils.SendDocumentUploadNotification(Membership.GetUser().UserName, documentID);
}
}
}
else if (collection["docfileadd"].ToString().Equals("hyperlink"))
{
collection["DocName"] = collection["txtHyperlinkAdd"];
collection["DocPath"] = null;
collection["DocAccess"] = collection["ddDocumentTypeEdit"];
int documentID = UpdateUtils.InsertDocuments(collection, int.Parse(_SourceID),
int.Parse(_SourceType));
//NEED TO COME BACK TO THIS
UpdateUtils.SendDocumentUploadNotification(System.Web.HttpContext.Current.User.Identity.Name, documentID);
}
//return View();
ViewData["Documents"] = docs.getDocumentsByID(int.Parse(_SourceID),
int.Parse(_SourceType),UpdateUtils.ROLE_ALL);
ViewData["ReviewID"] = _ReviewID;
ViewData["PALibID"] = _PALibID;
ViewData["PActionID"] = _SourceID;
ViewData["contributor"] = _contributor;
return PartialView("display_documents");
//return RedirectToAction("ParagraphDetails", new { ReviewID = int.Parse(_ReviewID), PALibID = int.Parse(_PALibID) });
//return RedirectToAction("Details");
}
catch
{
return null;
}
}