//добавление оценки экспертом экспертизе pospelov public int AddMarkPospelov(int id_expertise, int id_expert, Dictionary <int, float> dic_ribs_val, Dictionary <int, float> dic_facs_val) { try { foreach (var dic in dic_ribs_val) { marks_ribs res = new marks_ribs(); res.id_expertise = id_expertise; res.id_expert = id_expert; res.id_rib = dic.Key; res.value = dic.Value; db_Expertises.marks_ribs.Add(res); db_Expertises.SaveChanges(); } foreach (var dic in dic_facs_val) { marks_factors res = new marks_factors(); res.id_expertise = id_expertise; res.id_expert = id_expert; res.id_factor = dic.Key; res.value = dic.Value; db_Expertises.marks_factors.Add(res); db_Expertises.SaveChanges(); } return(id_expertise); } catch (Exception ex) { return(-1); } }
// Получение данных по экспертизе поспелова для ексель public view_completed_expertise_pospelov GetListExpertiseReportPospelov(int id_expertise) { try { view_completed_expertise_pospelov result = new view_completed_expertise_pospelov(); expertises _expertises = db_Expertises.expertises.Where(o => o.id_expertise == id_expertise).FirstOrDefault(); List <marks_factors> ls_marks_factors = db_Expertises.marks_factors.Where(o => o.id_expertise == id_expertise).ToList(); List <marks_ribs> ls_marks_ribs = db_Expertises.marks_ribs.Where(o => o.id_expertise == id_expertise).ToList(); List <results_factors> ls_results_factors = db_Expertises.results_factors.Where(o => o.id_expertise == id_expertise).ToList(); List <results_ribs> ls_results_ribs = db_Expertises.results_ribs.Where(o => o.id_expertise == id_expertise).ToList(); expertises ex_new = new expertises(); ex_new.id_expertise = _expertises.id_expertise; ex_new.name = _expertises.name; ex_new.id_status = _expertises.id_status; ex_new.type = _expertises.type; List <marks_factors> temp_marks_fact = new List <marks_factors>(); foreach (var pr in ls_marks_factors) { marks_factors t = new marks_factors(); t.id_mark = pr.id_mark; t.id_factor = pr.id_factor; t.id_expertise = pr.id_expertise; t.id_expert = pr.id_expert; t.value = pr.value; t.factors = new factors(); t.factors.name = pr.factors.name; t.factors.id_factor = pr.factors.id_factor; t.factors.priority = pr.factors.priority; 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; temp_marks_fact.Add(t); } List <marks_ribs> temp_marks_ribs = new List <marks_ribs>(); foreach (var pr in ls_marks_ribs) { marks_ribs t = new marks_ribs(); t.id_rib = pr.id_rib; t.id_mark_rib = pr.id_mark_rib; t.id_expertise = pr.id_expertise; t.id_expert = pr.id_expert; t.value = pr.value; t.ribs = new ribs(); t.ribs.id_rib = pr.ribs.id_rib; t.ribs.id_factor_from = pr.ribs.id_factor_from; t.ribs.factors = new factors(); t.ribs.factors.id_factor = pr.ribs.factors.id_factor; t.ribs.factors.priority = pr.ribs.factors.priority; t.ribs.id_factor_in = pr.ribs.id_factor_in; t.ribs.factors1 = new factors(); t.ribs.factors1.id_factor = pr.ribs.factors1.id_factor; t.ribs.factors1.priority = pr.ribs.factors1.priority; 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; temp_marks_ribs.Add(t); } List <results_ribs> temp_results_ribs = new List <results_ribs>(); foreach (var pr in ls_results_ribs) { results_ribs t = new results_ribs(); t.id_rib = pr.id_rib; t.id_result_mark_rib = pr.id_result_mark_rib; t.id_expertise = pr.id_expertise; t.value = pr.value; t.ribs = new ribs(); t.ribs.id_rib = pr.ribs.id_rib; t.ribs.id_factor_from = pr.ribs.id_factor_from; t.ribs.factors = new factors(); t.ribs.factors.id_factor = pr.ribs.factors.id_factor; t.ribs.factors.priority = pr.ribs.factors.priority; t.ribs.id_factor_in = pr.ribs.id_factor_in; t.ribs.factors1 = new factors(); t.ribs.factors1.id_factor = pr.ribs.factors1.id_factor; t.ribs.factors1.priority = pr.ribs.factors1.priority; temp_results_ribs.Add(t); } List <results_factors> temp_results_fact = new List <results_factors>(); foreach (var pr in ls_results_factors) { results_factors t = new results_factors(); t.id_factor = pr.id_factor; t.id_expertise = pr.id_expertise; t.id_mark_result_factor = pr.id_mark_result_factor; t.value = pr.value; t.factors = new factors(); t.factors.name = pr.factors.name; t.factors.priority = pr.factors.priority; t.factors.id_factor = pr.factors.id_factor; temp_results_fact.Add(t); } result.id_expertise = id_expertise; result.expertises = ex_new; result.list_marks_factors = temp_marks_fact; result.list_marks_ribs = temp_marks_ribs; result.list_results_factors = temp_results_fact; result.list_results_ribs = temp_results_ribs; return(result); } catch (Exception ex) { view_completed_expertise_pospelov tmpC = new view_completed_expertise_pospelov(); tmpC.id_expertise = -1; return(tmpC); } }
public view_expertise_pospelov GetListExpertisePospelov(int id_expertise, int id_expert) { try { view_expertise_pospelov result = new view_expertise_pospelov(); expertises _expertises = db_Expertises.expertises.Where(p => p.id_expertise == id_expertise).FirstOrDefault(); if (_expertises != null) { List <factors> list_pr_ex = db_Expertises.factors.Where(p => p.id_expertise == id_expertise).ToList(); List <marks_ribs> list_marks_ribs = db_Expertises.marks_ribs.Where(p => p.id_expertise == id_expertise && p.id_expert == id_expert).ToList(); List <marks_factors> list_marks_factors = db_Expertises.marks_factors.Where(p => p.id_expertise == id_expertise && p.id_expert == id_expert).ToList(); List <factors> temp = new List <factors>(); List <ribs> temp2 = new List <ribs>(); foreach (var pr in list_pr_ex) { factors t = new factors(); t.id_expertise = pr.id_expertise; t.id_factor = pr.id_factor; t.priority = pr.priority; t.name = pr.name; List <ribs> list_ex_cr = db_Expertises.ribs.Where(p => p.id_factor_from == pr.id_factor).ToList(); if (list_ex_cr != null) { foreach (var pr2 in list_ex_cr) { ribs t2 = new ribs(); t2.id_rib = pr2.id_rib; t2.id_factor_from = pr2.id_factor_from; t2.id_factor_in = pr2.id_factor_in; temp2.Add(t2); } } temp.Add(t); } List <marks_factors> temp3 = new List <marks_factors>(); foreach (var pr in list_marks_factors) { marks_factors t = new marks_factors(); t.id_mark = pr.id_mark; t.id_expertise = pr.id_expertise; t.id_factor = pr.id_factor; t.id_expert = pr.id_expert; t.value = pr.value; temp3.Add(t); } List <marks_ribs> temp4 = new List <marks_ribs>(); foreach (var pr in list_marks_ribs) { marks_ribs t = new marks_ribs(); t.id_mark_rib = pr.id_mark_rib; t.id_expertise = pr.id_expertise; t.id_rib = pr.id_rib; t.id_expert = pr.id_expert; t.value = pr.value; temp4.Add(t); } result.id_expertise = id_expertise; result.list_factors = temp; result.list_ribs = temp2; result.list_marks_factors = temp3; result.list_marks_ribs = temp4; //return _expertises.id_expertise; } return(result); } catch (Exception Ex) { // тут логируется ошибка view_expertise_pospelov tmpC = new view_expertise_pospelov(); tmpC.id_expertise = -1; return(tmpC); } }