Пример #1
0
        private void UpdateTopicAndName(int reviewId)
        {
            FinalThesisReview review     = manager.GetReview(reviewId);
            SubmissionThesis  submission = manager.GetSubmissionForThesisId(review.FinalThesis.FinalThesisId);

            ViewBag.thesisTopic = submission.ThesisTopic;
            ViewBag.name        = review.FinalThesis.Participant.Name;
            ViewBag.surname     = review.FinalThesis.Participant.Surname;
        }
Пример #2
0
 public IActionResult Preview(int id)
 {
     if (id != 0)
     {
         FinalThesisReview finalThesisReview = manager.GetReview(id);
         SubmissionThesis  submission        = manager.GetSubmissionForThesisId(id);
         ViewBag.topic = submission.ThesisTopic;
         return(View(finalThesisReview));
     }
     return(View());
 }
Пример #3
0
        public void EditReviewStatusTest()
        {
            IDao manager = new DatabaseManager();

            try
            {
                manager.EditReviewStatus(-1, ThesisStatus.APPROVED);
                Assert.Fail();
            }
            catch
            {
            }
            try
            {
                manager.EditReviewStatus(100000, ThesisStatus.APPROVED);
                Assert.Fail();
            }
            catch
            {
            }
            try
            {
                manager.EditReviewStatus(1, ThesisStatus.DISCARD);
                FinalThesisReview review = manager.GetReview(1);
                Assert.IsTrue(review.FormStatus == ThesisStatus.DISCARD);
            }
            catch
            {
                Assert.Fail();
            }
            try
            {
                manager.EditReviewStatus(1, ThesisStatus.WAITING);
                FinalThesisReview review = manager.GetReview(1);
                Assert.IsTrue(review.FormStatus == ThesisStatus.WAITING);
            }
            catch
            {
                Assert.Fail();
            }
            try
            {
                manager.EditReviewStatus(1, ThesisStatus.APPROVED);
                FinalThesisReview review = manager.GetReview(1);
                Assert.IsTrue(review.FormStatus == ThesisStatus.APPROVED);
            }
            catch
            {
                Assert.Fail();
            }
        }
Пример #4
0
        // tested
        public void EditReview(FinalThesisReview review)
        {
            conn.Open();
            string sql = "UPDATE FinalThesesReview " +
                         $"SET titleCompability = '{review.TitleCompability}', thesisStructureComment = '{review.ThesisStructureComment}', " +
                         $"newProblem = '{review.NewProblem}', sourcesUse = '{review.SourcesUse}', " +
                         $"formalWorkSide = '{review.FormalWorkSide}', wayToUse = '{review.WayToUse}', " +
                         $"substantiveThesisGrade = '{review.SubstantiveThesisGrade}', thesisGrade = '{review.ThesisGrade}', " +
                         $"formDate = '{review.FormDate:yyyy-MM-dd}', formStatus = '3' " +
                         $"WHERE formId = {review.FormId}";
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Пример #5
0
        // non-tested
        public void AddReview(FinalThesisReview finalThesisReview)
        {
            conn.Open();
            string sql = "INSERT INTO FinalThesesReview " +
                         "(formId, titleCompability, thesisStructureComment, newProblem, sourcesUse," +
                         " formalWorkSide, wayToUse, substantiveThesisGrade, thesisGrade, formDate, " +
                         "formStatus, finalThesisId) VALUES " +
                         $"({finalThesisReview.FormId}, {finalThesisReview.TitleCompability}, {finalThesisReview.ThesisStructureComment}, " +
                         $"{finalThesisReview.NewProblem}, {finalThesisReview.SourcesUse}, {finalThesisReview.FormalWorkSide}, " +
                         $"{finalThesisReview.WayToUse}, {finalThesisReview.SubstantiveThesisGrade}, {finalThesisReview.ThesisGrade}, " +
                         $"'{finalThesisReview.FormDate?.ToString("yyyy-MM-dd")}', {finalThesisReview.FormStatus}, " +
                         $"{finalThesisReview.FinalThesis.FinalThesisId})";
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Пример #6
0
        // tested
        public FinalThesisReview GetReview(int reviewId)
        {
            conn.Open();
            string sql = $"SELECT FTR.*, P.*, L.* FROM FinalThesesReview FTR " +
                         $"JOIN FinalTheses FT ON FTR.finalThesisId = FT.finalThesisId " +
                         $"JOIN Participants P ON P.participantId = FT.participantId " +
                         $"JOIN Lecturers L ON L.lecturerId = FT.lecturerId " +
                         $"WHERE formId = {reviewId}";
            MySqlCommand    cmd = new MySqlCommand(sql, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            FinalThesisReview review = new FinalThesisReview();

            rdr.Read();
            review.FormId                 = int.Parse(rdr[0].ToString());
            review.TitleCompability       = rdr[1].ToString();
            review.ThesisStructureComment = rdr[2].ToString();
            review.NewProblem             = rdr[3].ToString();
            review.SourcesUse             = rdr[4].ToString();
            review.FormalWorkSide         = rdr[5].ToString();
            review.WayToUse               = rdr[6].ToString();
            review.SubstantiveThesisGrade = rdr[7].ToString();
            review.ThesisGrade            = rdr[8].ToString();
            review.FormDate               = DateTime.Parse(rdr[9].ToString());
            review.FormStatus             = (ThesisStatus)int.Parse(rdr[10].ToString());

            FinalThesis finalThesis = new FinalThesis();

            finalThesis.FinalThesisId = int.Parse(rdr[11].ToString());
            int dataOffset = 12;

            finalThesis.Participant = GetParticipantFromReader(rdr, dataOffset);
            review.FinalThesis      = finalThesis;

            Lecturer lecturer = new Lecturer();

            lecturer.LecturerId = int.Parse(rdr[24].ToString());
            lecturer.UserId     = int.Parse(rdr[25].ToString());

            rdr.Close();
            conn.Close();
            FillUserData(lecturer);
            FillUserData(finalThesis.Participant);
            finalThesis.Lecturer = lecturer;
            return(review);
        }
Пример #7
0
        // tested
        public List <FinalThesisReview> GetReviews(int lecturerId)
        {
            List <FinalThesisReview> reviews = new List <FinalThesisReview>();

            conn.Open();
            string sql = $"SELECT FTR.*, P.* " +
                         "FROM Lecturers L " +
                         "NATURAL JOIN FinalTheses FT " +
                         "JOIN Participants P ON FT.participantId = P.participantId " +
                         "JOIN FinalThesesReview FTR ON FTR.finalThesisId = FT.finalThesisId " +
                         $"WHERE L.lecturerId = {lecturerId}";
            MySqlCommand    cmd = new MySqlCommand(sql, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                FinalThesisReview review = new FinalThesisReview();
                review.FormId                 = int.Parse(rdr[0].ToString());
                review.TitleCompability       = rdr[1].ToString();
                review.ThesisStructureComment = rdr[2].ToString();
                review.NewProblem             = rdr[3].ToString();
                review.SourcesUse             = rdr[4].ToString();
                review.FormalWorkSide         = rdr[5].ToString();
                review.WayToUse               = rdr[6].ToString();
                review.SubstantiveThesisGrade = rdr[7].ToString();
                review.ThesisGrade            = rdr[8].ToString();
                review.FormDate               = DateTime.Parse(rdr[9].ToString());
                review.FormStatus             = (ThesisStatus)int.Parse(rdr[10].ToString());
                FinalThesis finalThesis = new FinalThesis();
                finalThesis.FinalThesisId = int.Parse(rdr[11].ToString());
                int dataOffset = 12;
                finalThesis.Participant = GetParticipantFromReader(rdr, dataOffset);
                review.FinalThesis      = finalThesis;

                reviews.Add(review);
            }
            rdr.Close();
            conn.Close();
            foreach (FinalThesisReview r in reviews)
            {
                FillUserData(r.FinalThesis.Participant);
            }
            return(reviews);
        }
Пример #8
0
        public IActionResult Edit(int id, IFormCollection form)
        {
            List <bool> fieldsValidation = GetReviewFieldsValidation(form);
            bool        dataIsValid      = true;

            foreach (bool fieldValidation in fieldsValidation)
            {
                if (!fieldValidation)
                {
                    dataIsValid = false;
                }
            }

            UpdateTopicAndName(id);
            ViewBag.dataIsValid = dataIsValid;
            ViewBag.form        = form;

            if (!dataIsValid)
            {
                ViewBag.fieldsValidation = fieldsValidation;
                return(View());
            }

            FinalThesisReview review = new FinalThesisReview();

            review.FormId                 = id;
            review.TitleCompability       = form["TitleCompability"];
            review.ThesisStructureComment = form["ThesisStructureComment"];
            review.NewProblem             = form["NewProblem"];
            review.SourcesUse             = form["SourcesUse"];
            review.FormalWorkSide         = form["FormalWorkSide"];
            review.WayToUse               = form["WayToUse"];
            review.SubstantiveThesisGrade = form["SubstantiveThesisGrade"];
            review.ThesisGrade            = form["ThesisGrade"];
            review.FormDate               = DateTime.Parse(form["FormDate"]);

            manager.EditReview(review);

            return(RedirectToAction("Index"));
        }