Beispiel #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());
            }
        }
Beispiel #2
0
        //
        // GET: /Document/

        public ActionResult Index()
        {
            CandidateWebServiceReference.Candidate c = null;
            using (var service = new CandidateWebServiceReference.CandidatesService())
            {
                c = service.GetCandidateByLogin(this.GetLogin());
            }

            return(View(c));
        }
Beispiel #3
0
        public ActionResult Documents()
        {
            HttpCookie authCookie            = Request.Cookies[FormsAuthentication.FormsCookieName];
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

            CandidateWebServiceReference.Candidate candidate = null;
            using (var service = new CandidateWebServiceReference.CandidatesService())
            {
                candidate = service.GetCandidateByLogin(ticket.Name);
            }

            if (candidate == null)
            {
                ModelState.AddModelError("", "Error in documents!");
                return(RedirectToAction("Index", "Home"));
            }

            return(View(candidate));
        }
Beispiel #4
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());
            }
        }