public async Task <IActionResult> Create(EvaluationCommittee evaluationCommittee)
        {
            if (ModelState.IsValid)
            {
                var ec = _context.EvaluationCommittees.Where(e => e.LecturerId == evaluationCommittee.LecturerId);
                if (ec.Any())
                {
                    ModelState.AddModelError(string.Empty, "Error, This member is already available.");
                    ViewData["LecturerId"]  = new SelectList(_context.Lecturers, "Id", "Name", evaluationCommittee.LecturerId);
                    ViewData["CommitteeId"] = new SelectList(_context.Committees, "Id", "Name", evaluationCommittee.CommitteeId);
                    ViewData["Lecturers"]   = new List <Models.Lecturer>(_context.Lecturers).ToList();

                    return(View(evaluationCommittee));
                }

                _context.Add(evaluationCommittee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LecturerId"]  = new SelectList(_context.Lecturers, "Id", "Name", evaluationCommittee.LecturerId);
            ViewData["CommitteeId"] = new SelectList(_context.Committees, "Id", "Name", evaluationCommittee.CommitteeId);
            ViewData["Lecturers"]   = new List <Models.Lecturer>(_context.Lecturers).ToList();

            return(View(evaluationCommittee));
        }
        public void AddCommittee(List <dtoCommittee> committees, Boolean useDssMethod, String name, String description)
        {
            long  idCall                  = View.IdCall;
            Int32 idCommunity             = View.IdCommunity;
            EvaluationCommittee committee = Service.AddCommitteeToCall(idCall, committees, name, description, useDssMethod, (useDssMethod ? View.GetCallDssSettings() : null));

            if (committee == null)
            {
                View.DisplayError(EvaluationEditorErrors.AddingCommittee);
            }
            else
            {
                View.SendUserAction(idCommunity, View.IdCallModule, idCall, ModuleCallForPaper.ActionType.AddCommittee);
                View.ReloadEditor(RootObject.CommitteeAddedToCall(committee.Id, idCall, idCommunity, View.PreloadView));
            }
        }
        public async Task <IActionResult> Edit(int id, EvaluationCommittee evaluationCommittee)
        {
            if (id != evaluationCommittee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var ec = _context.EvaluationCommittees.Where(e => e.LecturerId == evaluationCommittee.LecturerId);
                    if (ec.Any())
                    {
                        ModelState.AddModelError(string.Empty, "Error, This member is already available.");
                        ViewData["LecturerId"]  = new SelectList(_context.Lecturers, "Id", "Name", evaluationCommittee.LecturerId);
                        ViewData["CommitteeId"] = new SelectList(_context.Committees, "Id", "Name", evaluationCommittee.CommitteeId);
                        ViewData["Lecturers"]   = new List <Models.Lecturer>(_context.Lecturers).ToList();

                        return(View(evaluationCommittee));
                    }
                    _context.Update(evaluationCommittee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EvaluationCommitteeExists(evaluationCommittee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LecturerId"]  = new SelectList(_context.Lecturers, "Id", "Name", evaluationCommittee.LecturerId);
            ViewData["CommitteeId"] = new SelectList(_context.Committees, "Id", "Name", evaluationCommittee.CommitteeId);
            ViewData["Lecturers"]   = new List <Models.Lecturer>(_context.Lecturers).ToList();

            return(View(evaluationCommittee));
        }
        private void LoadCommittees(BaseForPaper call, Boolean allowUseOfDssMethods, long idMethod = -1, long idRatingSet = -1)
        {
            List <dtoCommittee>     committees = Service.GetEditorCommittees(call);
            List <dtoSubmitterType> submitters = CallService.GetCallAvailableSubmittersType(call);
            CallForPaper            cfp        = Service.GetCallForCommiteeSettings(call.Id);
            Boolean useDssMethod = allowUseOfDssMethods && (cfp != null && cfp != null && cfp.EvaluationType == EvaluationType.Dss);

            View.AllowSubmittersSelection = !useDssMethod && (committees.Count > 0) && submitters.Count > 0;
            View.UseDssMethods            = useDssMethod;
            View.LoadSubmitterTypes(submitters);

            List <lm.Comol.Core.Wizard.NavigableWizardItem <dtoEvaluationStep> > steps = Service.GetAvailableSteps(call, WizardEvaluationStep.none);
            Int32 count = committees.Count;

            View.CommitteesCount = count;
            List <dtoSelectMethod> methods = null;

            if (useDssMethod)
            {
                methods             = ServiceDss.MethodsGetAvailable(UserContext.Language.Id);
                View.CurrentMethods = methods;
            }
            if (committees == null || committees.Count == 0)
            {
                if (!Service.isNewCommittee(call))
                {
                    View.CommitteesCount = 0;
                    View.DisplayError(EvaluationEditorErrors.NoCommittees);
                    View.LoadWizardSteps(call.Id, View.IdCommunity, steps, EvaluationEditorErrors.NoCommittees);
                    View.DisplayDssErrors(new List <dtoCommittee>());
                }
                else
                {
                    EvaluationCommittee committee = Service.AddFirstCommittee(call, View.DefaultCommitteeName, View.DefaultCommitteeDescription, useDssMethod);
                    if (committee != null)
                    {
                        committees = new List <dtoCommittee>();
                        committees.Add(new dtoCommittee()
                        {
                            Id = committee.Id, Description = committee.Description, DisplayOrder = committee.DisplayOrder, UseDss = committee.UseDss, WeightSettings = new Core.Dss.Domain.Templates.dtoItemWeightSettings(), MethodSettings = new Core.Dss.Domain.Templates.dtoItemMethodSettings()
                            {
                                InheritsFromFather = false
                            }, Name = committee.Name, ForAllSubmittersType = true
                        });
                        count = 1;
                        View.CommitteesCount = count;
                        View.LoadCommittees(committees);
                    }
                    else
                    {
                        View.CommitteesCount = 0;
                    }
                    if (useDssMethod && committees.Any(c => c.HasDssErrors(count)))
                    {
                        //lm.Comol.Core.Wizard.NavigableWizardItem<dtoEvaluationStep> step = steps.Where(s=> s.Id.Type== WizardEvaluationStep.GeneralSettings).FirstOrDefault();
                        //if (step!=null){
                        //    step.Id.Errors.Add(EditingErrors.CommitteeDssSettings);
                        //    if (step.Status== Core.Wizard.WizardItemStatus.valid || step.Status== Core.Wizard.WizardItemStatus.none)
                        //        step.Status= Core.Wizard.WizardItemStatus.error;
                        //}
                        View.DisplayDssErrors(committees.Where(c => c.HasDssErrors(1)).ToList());
                    }
                    else
                    {
                        View.DisplayDssErrors(new List <dtoCommittee>());
                    }
                    View.LoadWizardSteps(call.Id, View.IdCommunity, steps);
                }
            }
            else
            {
                if (useDssMethod && committees.Any(c => c.HasDssErrors(count)))
                {
                    View.DisplayDssErrors(committees.Where(c => c.HasDssErrors(count)).ToList());
                    //lm.Comol.Core.Wizard.NavigableWizardItem<dtoEvaluationStep> step = steps.Where(s => s.Id.Type == WizardEvaluationStep.GeneralSettings).FirstOrDefault();
                    //if (step != null)
                    //{
                    //    step.Id.Errors.Add(EditingErrors.CommitteeDssSettings);
                    //    if (step.Status == Core.Wizard.WizardItemStatus.valid || step.Status == Core.Wizard.WizardItemStatus.none)
                    //        step.Status = Core.Wizard.WizardItemStatus.error;
                    //}
                }
                else
                {
                    View.DisplayDssErrors(new List <dtoCommittee>());
                }
                View.LoadWizardSteps(call.Id, View.IdCommunity, steps);
                if (useDssMethod)
                {
                    if (committees.Count > 1)
                    {
                        View.InitializeAggregationMethods(methods, (idMethod == -1 ? cfp.IdDssMethod : idMethod), (idRatingSet == -1 ? cfp.IdDssRatingSet : idRatingSet), GetAvailableWeights(call, call.IsDssMethodFuzzy, call.UseOrderedWeights, committees));
                    }
                    else
                    {
                        View.HideCallAggregationMethods(methods, (idMethod == -1 ? cfp.IdDssMethod : idMethod), (idRatingSet == -1 ? cfp.IdDssRatingSet : idRatingSet), GetAvailableWeights(call, call.IsDssMethodFuzzy, call.UseOrderedWeights, committees));
                    }
                }


                View.LoadCommittees(committees);
            }
        }