//Метод добавления оценки по проекту экспертом 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); } }
//получения данных по экпертизе Паттерн для вывода в ексель 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); } }