Esempio 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);
            }
        }
Esempio n. 2
0
        //Метод добавления оценки по проекту экспертом
        public int AddResultExpert(int id_expertise, int id_expert, int id_project, 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)
                {
                    results_experts res = db_Expertises.results_experts.Where(o => o.id_expert == id_expert && o.id_expertise == id_expertise && o.id_project == id_project).FirstOrDefault();
                    if (res != null)
                    {
                        res.id_expertise = id_expertise;
                        res.id_expert    = id_expert;
                        res.id_project   = id_project;
                        res.value        = value;

                        db_Expertises.SaveChanges();
                        return(res.id_result_expert);
                    }
                    else
                    {
                        res = new results_experts();
                        res.id_expertise = id_expertise;
                        res.id_expert    = id_expert;
                        res.id_project   = id_project;
                        res.value        = value;
                        db_Expertises.results_experts.Add(res);
                        db_Expertises.SaveChanges();
                        return(res.id_result_expert);
                    }
                }
                else
                {
                    results_experts res = new results_experts();
                    res.id_expertise = id_expertise;
                    res.id_expert    = id_expert;
                    res.id_project   = id_project;
                    res.value        = value;
                    db_Expertises.results_experts.Add(res);
                    db_Expertises.SaveChanges();
                    return(res.id_result_expert);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        //Метод добавления статуса экспертизы для эксперта
        public int AddStatusExpertiseExpert(int id_expertise, int id_expert)
        {
            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 == 1)
                {
                    experts_Expertises.id_status = 2;
                    db_Expertises.SaveChanges();

                    int res = AddStatusExpertise(experts_Expertises.id_expertise);
                    return(res);
                }
                return(-1);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
Esempio n. 5
0
        //Метод добавления экспертизы pospelov
        public int AddExperisePospelov(string name, List <int> ls_id_experts, List <List <string> > ls_fac /*List<int> ls_prior, List<string> ls_name_fact*/)
        {
            try
            {
                expertises _expertises = new expertises();
                _expertises.name      = name;
                _expertises.id_status = 1;
                _expertises.type      = 2;
                db_Expertises.expertises.Add(_expertises);
                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();
                }
                int level = 0;
                foreach (var temp in ls_fac)
                {
                    for (int i = 0; i < temp.Count(); i++)
                    {
                        factors fc = new factors();
                        fc.id_expertise = _expertises.id_expertise;
                        fc.name         = temp[i];
                        fc.priority     = level;
                        db_Expertises.factors.Add(fc);
                        db_Expertises.SaveChanges();
                    }
                    level++;
                }
                int max_priority = ls_fac.Count();
                level = 0;
                foreach (var temp in ls_fac)
                {
                    if (level != max_priority)
                    {
                        for (int i = 0; i < temp.Count(); i++)
                        {
                            string name_fact = temp[i];
                            var    id_factor = db_Expertises.factors.Where(o => o.id_expertise == _expertises.id_expertise && o.name == name_fact).FirstOrDefault().id_factor;

                            List <factors> tmpFactors = db_Expertises.factors.Where(o => o.priority == level + 1 && o.id_expertise == _expertises.id_expertise).ToList();
                            foreach (var fact in tmpFactors)
                            {
                                ribs r = new ribs();
                                r.id_factor_from = id_factor;
                                r.id_factor_in   = fact.id_factor;
                                db_Expertises.ribs.Add(r);
                                db_Expertises.SaveChanges();
                            }
                        }
                        level++;
                    }
                }
                return(_expertises.id_expertise);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }