예제 #1
0
        public bool UpdateExamPaper(ServerInterfaces.ExamPaper paper)
        {
            bool IsExamPaperUpdated;

            try
            {
                using (AdmissionTestingSystemEntities db = new AdmissionTestingSystemEntities())
                {
                    var exam = (from examPaper in db.ExamPapers
                                where examPaper.Id == paper.Id
                                select examPaper).FirstOrDefault();

                    exam.MarksPerQuestion = paper.MarksPerQuestion;
                    exam.Name             = paper.Name;
                    exam.TotalQuestions   = paper.TotalQuestions;
                    exam.TimeDuration     = paper.TimeDuration;

                    db.SaveChanges();
                    Console.WriteLine("Data Saved Successfully");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                IsExamPaperUpdated = true;
            }
            return(IsExamPaperUpdated);
        }
예제 #2
0
        /// <summary>
        /// Function to get all the courses id from the data base used in paper pool module
        /// </summary>
        /// <returns></returns>
        public List <ServerInterfaces.ExamPaper> getAllCourses()
        {
            List <ServerInterfaces.ExamPaper> paperList = new List <ServerInterfaces.ExamPaper>();

            using (AdmissionTestingSystemEntities db = new AdmissionTestingSystemEntities())
            {
                var examPaper = from paper in db.ExamPapers select paper;
                foreach (ExamPaper info in examPaper)
                {
                    ServerInterfaces.ExamPaper epaper = new ServerInterfaces.ExamPaper();
                    epaper.Id = info.Id;
                    paperList.Add(epaper);
                }
            }

            return(paperList);
        }
예제 #3
0
        public bool AddExamPaper(ServerInterfaces.ExamPaper paper)
        {
            bool IsExamPaperAdded = false;

            try
            {
                Console.WriteLine("In to the Add Exam Paper Section");
                using (AdmissionTestingSystemEntities db = new AdmissionTestingSystemEntities())
                {
                    ExamPaper papers = new ExamPaper();
                    papers.Id               = paper.Id;
                    papers.Name             = paper.Name;
                    papers.TimeDuration     = paper.TimeDuration;
                    papers.TotalQuestions   = paper.TotalQuestions;
                    papers.MarksPerQuestion = paper.MarksPerQuestion;
                    db.ExamPapers.Add(papers);
                    db.SaveChanges();
                    IsExamPaperAdded = true;
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                // Console.WriteLine(ex.Message);
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                Console.WriteLine(raise.Message);
                throw raise;
            }
            Console.WriteLine("End Section");
            return(IsExamPaperAdded);
        }
예제 #4
0
        public List <ServerInterfaces.ExamPaper> getExamPaperCourse()
        {
            List <ServerInterfaces.ExamPaper> examPaperList = new List <ServerInterfaces.ExamPaper>();

            using (AdmissionTestingSystemEntities db = new AdmissionTestingSystemEntities())
            {
                var examPaper = from papers in db.ExamPapers select papers;
                foreach (ExamPaper paper in examPaper)
                {
                    ServerInterfaces.ExamPaper examPaperObj = new ServerInterfaces.ExamPaper();
                    examPaperObj.Id               = paper.Id;
                    examPaperObj.Name             = paper.Name;
                    examPaperObj.TotalQuestions   = paper.TotalQuestions;
                    examPaperObj.TimeDuration     = paper.TimeDuration;
                    examPaperObj.MarksPerQuestion = paper.MarksPerQuestion;


                    examPaperList.Add(examPaperObj);
                }
            }

            return(examPaperList);
        }