Beispiel #1
0
        public Paper GetPaperDetails(int id)
        {
            Paper paper = new Paper();
            List <PaperAuthors> lstPaperAuth = new List <PaperAuthors>();
            string queryPaper = "SELECT PAP.PaperId, MainTitle, ShortDesc, Subject, Tags,PAP.CreatedBy, PAP.CreatedDateTime,  "
                                + " CompleteFilePath, FileName, CompleteDeclarationFilePath, DeclarationFileName,  AuthorFirstName, AuthorLastName,  "
                                + " AuthorDepartment, AuthorOrganisation, AuthorSubject, comments from Papers PAP "
                                + " INNER JOIN authors AUT ON PAP.PaperId = AUT.PaperID "
                                + " LEFT OUTER JOIN papercomments COM ON PAP.PaperId = COM.PaperId "
                                + "  AND COM.CommentsID = (SELECT MAX(CommentsID) from papercomments WHERE PaperId = ?PaperId) "
                                + " WHERE PAP.IsActive = 1 AND PAP.PaperId = ?PaperId ";


            MySqlCommand cmd = new MySqlCommand();

            cmd.Parameters.Add(new MySqlParameter("?PaperId", id));

            using (MySqlConnection con = new MySqlConnection(DBConnection.ConnectionString))
            {
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = queryPaper;

                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    PaperAuthors  auth     = new PaperAuthors();
                    PaperComments comments = new PaperComments();

                    paper.PaperId              = Convert.ToInt32(reader["PaperId"]);
                    paper.MainTitle            = reader["MainTitle"].ToString();
                    paper.ShortDesc            = reader["ShortDesc"].ToString();
                    paper.CreatedBy            = reader["CreatedBy"].ToString();
                    paper.Subject              = Convert.ToString(reader["Subject"]);
                    paper.Tags                 = Convert.ToString(reader["Tags"]);
                    paper.PaperPath            = Convert.ToString(reader["CompleteFilePath"]);
                    paper.FileName             = Convert.ToString(reader["FileName"]);
                    paper.PaperPath            = string.Format("{0}\\{1}", paper.PaperPath, paper.FileName);
                    paper.CreatedDateTime      = Convert.ToDateTime(reader["CreatedDateTime"].ToString());
                    paper.DeclarationFileName  = Convert.ToString(reader["DeclarationFileName"]);
                    paper.DeclarationPaperPath = Convert.ToString(reader["CompleteDeclarationFilePath"]);
                    //paper.DeclarationPaperPath = string.Format("{0}\\{1}", paper.DeclarationPaperPath, paper.DeclarationFileName);

                    auth.AuthorFirstName = Convert.ToString(reader["AuthorFirstName"]);
                    auth.AuthorLastName  = Convert.ToString(reader["AuthorLastName"]);
                    auth.Department      = Convert.ToString(reader["AuthorDepartment"]);
                    auth.Organisation    = Convert.ToString(reader["AuthorOrganisation"]);
                    auth.Subject         = Convert.ToString(reader["AuthorSubject"]);

                    comments.Comments = Convert.ToString(reader["comments"]);
                    paper.Comments    = comments;
                    lstPaperAuth.Add(auth);
                }

                paper.Authors = lstPaperAuth;
            }

            return(paper);
        }
Beispiel #2
0
        //[ValidateAntiForgeryToken]
        public ActionResult PostPaper(Paper paper, HttpPostedFileBase PaperPath, HttpPostedFileBase DeclarationPaperPath,
                                      string AuthorFirstName1, string AuthorLastName1, string AuthorDepartment1, string AuthorOrganisation1,
                                      string AuthorFirstName2, string AuthorLastName2, string AuthorDepartment2, string AuthorOrganisation2,
                                      string AuthorFirstName3, string AuthorLastName3, string AuthorDepartment3, string AuthorOrganisation3,
                                      string AuthorFirstName4, string AuthorLastName4, string AuthorDepartment4, string AuthorOrganisation4)
        {
            ActionResult result = this.ValidateAuthorToken();

            if (result != null)
            {
                return(result);
            }

            List <Specialisation> specialisations = _author.GetSpecialisation();

            ViewData["Subject"] = new SelectList((System.Collections.IEnumerable)specialisations, "specialisation", "specialisation");


            try
            {
                Paper newPaper = new Paper();
                List <PaperAuthors> authors = new List <PaperAuthors>();
                paper.CreatedBy = HttpContext.Session["FirstName"].ToString();
                paper.UpdatedBy = HttpContext.Session["FirstName"].ToString();
                newPaper        = paper;

                string uploadedPath   = Server.MapPath("~/UploadedFiles/AuthorPapers/");
                string sPaperPathName = Path.GetFileName(PaperPath.FileName);
                paper.FileName  = string.Format("{0}-{1}{2}", Path.GetFileNameWithoutExtension(sPaperPathName), Guid.NewGuid().ToString("N"), Path.GetExtension(sPaperPathName));
                paper.PaperPath = uploadedPath;

                string declarationPath = Server.MapPath("~/UploadedFiles/Declaration/");
                string sDecFileName    = Path.GetFileName(DeclarationPaperPath.FileName);
                paper.DeclarationFileName  = string.Format("{0}-{1}{2}", Path.GetFileNameWithoutExtension(sDecFileName), Guid.NewGuid().ToString("N"), Path.GetExtension(sDecFileName));
                paper.DeclarationPaperPath = declarationPath;

                if (!string.IsNullOrEmpty(AuthorFirstName1))
                {
                    PaperAuthors paperAuthors1 = new PaperAuthors();
                    paperAuthors1.AuthorFirstName = AuthorFirstName1;
                    paperAuthors1.AuthorLastName  = AuthorLastName1;
                    paperAuthors1.Department      = AuthorDepartment1;
                    paperAuthors1.Organisation    = AuthorDepartment1;
                    authors.Add(paperAuthors1);
                }

                if (!string.IsNullOrEmpty(AuthorFirstName2))
                {
                    PaperAuthors paperAuthors2 = new PaperAuthors();
                    paperAuthors2.AuthorFirstName = AuthorFirstName2;
                    paperAuthors2.AuthorLastName  = AuthorLastName2;
                    paperAuthors2.Department      = AuthorDepartment2;
                    paperAuthors2.Organisation    = AuthorDepartment2;
                    authors.Add(paperAuthors2);
                }

                if (!string.IsNullOrEmpty(AuthorFirstName3))
                {
                    PaperAuthors paperAuthors3 = new PaperAuthors();
                    paperAuthors3.AuthorFirstName = AuthorFirstName3;
                    paperAuthors3.AuthorLastName  = AuthorLastName3;
                    paperAuthors3.Department      = AuthorDepartment3;
                    paperAuthors3.Organisation    = AuthorDepartment3;
                    authors.Add(paperAuthors3);
                }

                if (!string.IsNullOrEmpty(AuthorFirstName4))
                {
                    PaperAuthors paperAuthors4 = new PaperAuthors();
                    paperAuthors4.AuthorFirstName = AuthorFirstName4;
                    paperAuthors4.AuthorLastName  = AuthorLastName4;
                    paperAuthors4.Department      = AuthorDepartment4;
                    paperAuthors4.Organisation    = AuthorDepartment4;
                    authors.Add(paperAuthors4);
                }

                newPaper.Authors = authors;
                newPaper.UserId  = int.Parse(HttpContext.Session["UserId"].ToString());
                _author.PostPapers(paper);

                if (!string.IsNullOrEmpty(paper.PaperPath))
                {
                    PaperPath.SaveAs(Path.Combine(paper.PaperPath, paper.FileName));
                }

                if (!string.IsNullOrEmpty(paper.DeclarationPaperPath))
                {
                    DeclarationPaperPath.SaveAs(Path.Combine(paper.DeclarationPaperPath, paper.DeclarationFileName));
                }

                ViewData["PaperPostingFailed"] = "Paper posted successfully.";
            }
            catch (Exception ex)
            {
                ViewData["PaperPostingFailed"] = "Error in posting paper. Please contact administrator";
            }

            ModelState.Clear();
            return(View());
        }