コード例 #1
0
        //Метод добавления экспертизы pattern
        public int AddExperisePattern(string name, List <int> ls_id_projects, List <int> ls_id_experts, Dictionary <int, float> dc_weight_criteries)
        {
            try
            {
                expertises _expertises = new expertises();
                _expertises.name      = name;
                _expertises.id_status = 1;
                _expertises.type      = 1;
                db_Expertises.expertises.Add(_expertises);
                db_Expertises.SaveChanges();

                foreach (int temp in ls_id_projects)
                {
                    projects_expertises pr_ex = new projects_expertises();
                    pr_ex.id_expertise = _expertises.id_expertise;
                    pr_ex.id_project   = temp;
                    db_Expertises.projects_expertises.Add(pr_ex);
                    db_Expertises.SaveChanges();
                }
                foreach (int temp in ls_id_experts)
                {
                    experts_expertises ex_ex = new experts_expertises();
                    ex_ex.id_expertise = _expertises.id_expertise;
                    ex_ex.id_expert    = temp;
                    ex_ex.id_status    = 1;
                    db_Expertises.experts_expertises.Add(ex_ex);
                    db_Expertises.SaveChanges();
                }
                foreach (var temp in dc_weight_criteries)
                {
                    expertises_criterions ex_cr = new expertises_criterions();
                    ex_cr.id_expertise = _expertises.id_expertise;
                    ex_cr.id_criterion = temp.Key;
                    ex_cr.weight       = temp.Value;
                    db_Expertises.expertises_criterions.Add(ex_cr);
                    db_Expertises.SaveChanges();
                }

                return(_expertises.id_expertise);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
コード例 #2
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);
            }
        }