Пример #1
0
 public bool DeletePPEExamBlank(PPEExamBlank exam_blanks)
 {
     return(TryFunc <bool>(() =>
     {
         bool res = false;
         using (EGESupportEntities context = new EGESupportEntities())
         {
             IEnumerable <journals> jours = context.journals.Where(x => x.ppe_exam_id == exam_blanks.ppe_exam_id && x.auditorium == exam_blanks.aud);
             context.journals.RemoveRange(jours);
             context.SaveChanges();
             res = true;
         }
         return res;
     }));
 }
Пример #2
0
        public int InsertPPEExamBlank(PPEExamBlank exam_blanks)
        {
            return(TryFunc <int>(() =>
            {
                int aud = exam_blanks.aud;
                using (EGESupportEntities context = new EGESupportEntities())
                {
                    if (exam_blanks.count_r > 0)
                    {
                        context.journals.Add(new journals()
                        {
                            ppe_exam_id = exam_blanks.ppe_exam_id,
                            blank_type_id = 1,
                            auditorium = exam_blanks.aud,
                            count_blanks = exam_blanks.count_r,
                            count_add_blanks = 0
                        });
                    }

                    if (exam_blanks.count_1 > 0)
                    {
                        context.journals.Add(new journals()
                        {
                            ppe_exam_id = exam_blanks.ppe_exam_id,
                            blank_type_id = 2,
                            auditorium = exam_blanks.aud,
                            count_blanks = exam_blanks.count_1,
                            count_add_blanks = 0
                        });
                    }

                    if (exam_blanks.count_2 > 0)
                    {
                        context.journals.Add(new journals()
                        {
                            ppe_exam_id = exam_blanks.ppe_exam_id,
                            blank_type_id = 3,
                            auditorium = exam_blanks.aud,
                            count_blanks = exam_blanks.count_2,
                            count_add_blanks = exam_blanks.count_add_2
                        });
                    }
                    context.SaveChanges();
                }
                return aud;
            }));
        }
Пример #3
0
        public void UpdatePPEExamBlank(PPEExamBlank exam_blanks, int old_aud)
        {
            TryFunc <bool>(() =>
            {
                bool res = false;
                using (EGESupportEntities context = new EGESupportEntities())
                {
                    IEnumerable <journals> jours = (from j in context.journals
                                                    where j.ppe_exam_id == exam_blanks.ppe_exam_id && j.auditorium == old_aud
                                                    select j);

                    journals jour = jours.Where(x => x.blank_type_id == 1).SingleOrDefault();
                    if (exam_blanks.count_r > 0)
                    {
                        if (jour != null)
                        {
                            jour.auditorium   = exam_blanks.aud;
                            jour.count_blanks = exam_blanks.count_r;
                        }
                        else
                        {
                            context.journals.Add(new journals()
                            {
                                ppe_exam_id      = exam_blanks.ppe_exam_id,
                                blank_type_id    = 1,
                                auditorium       = exam_blanks.aud,
                                count_blanks     = exam_blanks.count_r,
                                count_add_blanks = 0
                            });
                        }
                    }
                    else
                    {
                        if (jour != null)
                        {
                            context.journals.Remove(jour);
                        }
                    }

                    jour = jours.Where(x => x.blank_type_id == 2).SingleOrDefault();
                    if (exam_blanks.count_1 > 0)
                    {
                        if (jour != null)
                        {
                            jour.auditorium   = exam_blanks.aud;
                            jour.count_blanks = exam_blanks.count_1;
                        }
                        else
                        {
                            context.journals.Add(new journals()
                            {
                                ppe_exam_id      = exam_blanks.ppe_exam_id,
                                blank_type_id    = 2,
                                auditorium       = exam_blanks.aud,
                                count_blanks     = exam_blanks.count_1,
                                count_add_blanks = 0
                            });
                        }
                    }
                    else
                    {
                        if (jour != null)
                        {
                            context.journals.Remove(jour);
                        }
                    }

                    jour = jours.Where(x => x.blank_type_id == 3).SingleOrDefault();
                    if (exam_blanks.count_2 > 0)
                    {
                        if (jour != null)
                        {
                            jour.auditorium       = exam_blanks.aud;
                            jour.count_blanks     = exam_blanks.count_2;
                            jour.count_add_blanks = exam_blanks.count_add_2;
                        }
                        else
                        {
                            context.journals.Add(new journals()
                            {
                                ppe_exam_id      = exam_blanks.ppe_exam_id,
                                blank_type_id    = 3,
                                auditorium       = exam_blanks.aud,
                                count_blanks     = exam_blanks.count_2,
                                count_add_blanks = exam_blanks.count_add_2
                            });
                        }
                    }
                    else
                    {
                        if (jour != null)
                        {
                            context.journals.Remove(jour);
                        }
                    }
                    context.SaveChanges();
                    res = true;
                }
                return(res);
            });
        }