// // GET: /Document/Details/5 public ActionResult Details(int id) { DocumentWebServiceReference.Document d = null; using (var service = new DocumentWebServiceReference.DocumentsService()) { d = service.GetDocumentById(id, true); } return(File(d.File, d.Extension, d.Name + d.Extension)); }
// // GET: /Document/Edit/5 public ActionResult Edit(int id) { DocumentWebServiceReference.Document doc; using (var service = new DocumentWebServiceReference.DocumentsService()) { doc = service.GetDocumentById(id, true); } return(View(doc)); }
public ActionResult Edit(DocumentWebServiceReference.Document document) { try { DocumentWebServiceReference.Document tmpDoc = document; if (Request.Files["file1"].FileName != string.Empty) { byte[] buffer = new byte[Request.Files["file1"].ContentLength]; Request.Files["file1"].InputStream.Read(buffer, 0, buffer.Length); document.Extension = Request.Files["file1"].FileName.Substring(Request.Files["file1"].FileName.LastIndexOf('.')); document.File = buffer; } else { using (var service = new DocumentWebServiceReference.DocumentsService()) { tmpDoc = service.GetDocumentById(document.Id, true); } } document.CandidateIdSpecified = true; using (var service = new CandidateWebServiceReference.CandidatesService()) { document.CandidateId = service.GetCandidateByLogin(this.GetLogin()).Id; } using (var service = new DocumentWebServiceReference.DocumentsService()) { int ID; bool result; service.SaveDocument(tmpDoc, document.CandidateId, true, document.Type, true, out ID, out result); } return(RedirectToAction("Index")); } catch (Exception e) { return(View()); } }