Ejemplo n.º 1
0
        //Метод добавления оценки
        public int AddMark(int id_expertise, int id_expert, int id_project, int id_criterion, double value)
        {
            try
            {
                experts_expertises experts_Expertises = db_Expertises.experts_expertises.Where(o => o.id_expert == id_expert && o.id_expertise == id_expertise).FirstOrDefault();
                if (experts_Expertises != null && experts_Expertises.id_status == 2)
                {
                    marks _mark = db_Expertises.marks.Where(o => o.id_expert == id_expert && o.id_expertise == id_expertise && o.id_project == id_project && o.id_criterion == id_criterion).FirstOrDefault();
                    if (_mark != null)
                    {
                        _mark.id_expertise = id_expertise;
                        _mark.id_expert    = id_expert;
                        _mark.id_project   = id_project;
                        _mark.id_criterion = id_criterion;
                        _mark.value        = value;

                        db_Expertises.SaveChanges();
                        return(_mark.id_mark);
                    }
                    else
                    {
                        _mark = new marks();
                        _mark.id_expertise = id_expertise;
                        _mark.id_expert    = id_expert;
                        _mark.id_project   = id_project;
                        _mark.id_criterion = id_criterion;
                        _mark.value        = value;
                        db_Expertises.marks.Add(_mark);
                        db_Expertises.SaveChanges();
                        return(_mark.id_mark);
                    }
                }
                else
                {
                    marks _mark = new marks();
                    _mark.id_expertise = id_expertise;
                    _mark.id_expert    = id_expert;
                    _mark.id_project   = id_project;
                    _mark.id_criterion = id_criterion;
                    _mark.value        = value;
                    db_Expertises.marks.Add(_mark);
                    db_Expertises.SaveChanges();
                    return(_mark.id_mark);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
Ejemplo n.º 2
0
        //получения данных по экпертизе Паттерн для вывода в ексель
        public view_completed_expertise GetListExpertiseReport(int id_expertise)
        {
            try
            {
                view_completed_expertise result     = new view_completed_expertise();
                List <marks>             ls_marks   = db_Expertises.marks.Where(p => p.id_expertise == id_expertise).ToList();
                List <marks>             temp_marks = new List <marks>();
                foreach (var pr in ls_marks)
                {
                    marks t = new marks();
                    t.id_project          = pr.id_project;
                    t.id_expertise        = pr.id_expertise;
                    t.id_expert           = pr.id_expert;
                    t.id_criterion        = pr.id_criterion;
                    t.projects            = new projects();
                    t.projects.name       = pr.projects.name;
                    t.experts             = new experts();
                    t.experts.first_name  = pr.experts.first_name;
                    t.experts.second_name = pr.experts.second_name;
                    t.experts.patronymic  = pr.experts.patronymic;

                    t.criterions      = new criterions();
                    t.criterions.name = pr.criterions.name;
                    t.value           = pr.value;
                    temp_marks.Add(t);
                }
                List <results_experts> list_res_ex         = db_Expertises.results_experts.Where(p => p.id_expertise == id_expertise).ToList();
                List <results_experts> temp_result_experts = new List <results_experts>();
                foreach (var pr in list_res_ex)
                {
                    results_experts t = new results_experts();
                    t.id_project         = pr.id_project;
                    t.id_expertise       = pr.id_expertise;
                    t.id_expert          = pr.id_expert;
                    t.projects           = new projects();
                    t.projects.name      = pr.projects.name;
                    t.experts            = new experts();
                    t.experts.first_name = pr.experts.first_name;
                    t.value = pr.value;
                    temp_result_experts.Add(t);
                }
                List <results_expertises_criterions> ls_res_expertise_cr   = db_Expertises.results_expertises_criterions.Where(p => p.id_expertise == id_expertise).ToList();
                List <results_expertises_criterions> temp_res_expertise_cr = new List <results_expertises_criterions>();
                foreach (var pr in ls_res_expertise_cr)
                {
                    results_expertises_criterions t = new results_expertises_criterions();
                    t.id_project      = pr.id_project;
                    t.id_expertise    = pr.id_expertise;
                    t.id_criterion    = pr.id_criterion;
                    t.projects        = new projects();
                    t.projects.name   = pr.projects.name;
                    t.criterions      = new criterions();
                    t.criterions.name = pr.criterions.name;
                    t.value           = pr.value;
                    temp_res_expertise_cr.Add(t);
                }
                List <results_expertise> list_res_expertise = db_Expertises.results_expertise.Where(p => p.id_expertise == id_expertise).ToList();
                List <results_expertise> temp_res_expertise = new List <results_expertise>();
                foreach (var pr in list_res_expertise)
                {
                    results_expertise t = new results_expertise();
                    t.id_project    = pr.id_project;
                    t.id_expertise  = pr.id_expertise;
                    t.projects      = new projects();
                    t.projects.name = pr.projects.name;
                    t.value         = pr.value;
                    temp_res_expertise.Add(t);
                }
                result.id_expertise        = id_expertise;
                result.list_marks          = temp_marks;
                result.list_res_ex         = temp_result_experts;
                result.list_res_exppertise = temp_res_expertise;
                result.list_res_ex_cr      = temp_res_expertise_cr;

                return(result);
            }
            catch (Exception Ex)
            {
                // тут логируется ошибка
                view_completed_expertise tmpC = new view_completed_expertise();
                tmpC.id_expertise = -1;
                return(tmpC);
            }
        }
Ejemplo n.º 3
0
        //Метод получения конкретной экспертизы
        public view_expertise_criterios GetListExpertisesCriterions(int id_expertise, int id_expert)
        {
            try
            {
                view_expertise_criterios result = new view_expertise_criterios();
                expertises _expertises          = db_Expertises.expertises.Where(p => p.id_expertise == id_expertise).FirstOrDefault();
                if (_expertises != null)
                {
                    List <projects_expertises>   list_pr_ex = db_Expertises.projects_expertises.Where(p => p.id_expertise == id_expertise).ToList();
                    List <expertises_criterions> list_ex_cr = db_Expertises.expertises_criterions.Where(p => p.id_expertise == id_expertise).ToList();
                    List <marks> list_marks         = db_Expertises.marks.Where(p => p.id_expertise == id_expertise && p.id_expert == id_expert).ToList();
                    List <projects_expertises> temp = new List <projects_expertises>();
                    foreach (var pr in list_pr_ex)
                    {
                        projects_expertises t = new projects_expertises();
                        t.id_project = pr.id_project;
                        t.projects   = new projects();

                        t.projects.name = pr.projects.name;
                        temp.Add(t);
                    }
                    List <expertises_criterions> temp2 = new List <expertises_criterions>();
                    foreach (var pr in list_ex_cr)
                    {
                        expertises_criterions t = new expertises_criterions();
                        t.id_criterion    = pr.id_criterion;
                        t.weight          = pr.weight;
                        t.criterions      = new criterions();
                        t.criterions.name = pr.criterions.name;
                        temp2.Add(t);
                    }

                    List <marks> temp3 = new List <marks>();
                    foreach (var pr in list_marks)
                    {
                        marks t = new marks();
                        t.id_criterion = pr.id_criterion;
                        t.id_expert    = pr.id_expert;
                        t.id_project   = pr.id_project;
                        t.id_expertise = pr.id_expertise;
                        t.value        = pr.value;
                        temp3.Add(t);
                    }
                    result.id_expertise = id_expertise;
                    result.list_pr_ex   = temp;
                    result.list_ex_cr   = temp2;
                    result.list_marks   = temp3;

                    //return _expertises.id_expertise;
                }
                return(result);
            }
            catch (Exception Ex)
            {
                // тут логируется ошибка
                view_expertise_criterios tmpC = new view_expertise_criterios();
                tmpC.id_expertise = -1;


                return(tmpC);
            }
        }