コード例 #1
0
        public ActionResult Create(DocumentWebServiceReference.Document document)
        {
            try
            {
                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;

                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(document, document.CandidateId, true, document.Type, true, out ID, out result);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #2
0
        //
        // GET: /Document/Delete/5

        public ActionResult Delete(long id)
        {
            using (var service = new DocumentWebServiceReference.DocumentsService())
            {
                service.DeleteDocumenyById((long)id, true);
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        //
        // 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));
        }
コード例 #4
0
        //
        // 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));
        }
コード例 #5
0
        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());
            }
        }