private void LoadCallStatus(long idCall, dtoBaseForPaper call)
        {
            List <CallForPaperStatus> availableStatus = CallService.GetAvailableStatus(idCall);

            View.LoadStatus(availableStatus);
            View.CurrentStatus = ((idCall == 0 || !availableStatus.Any() || call == null)? CallForPaperStatus.Draft : (availableStatus.Contains(call.Status)? call.Status : availableStatus.FirstOrDefault()));
        }
        public void SaveSettings(dtoBaseForPaper dto, String submitterName, Boolean allowUseOfDss, Boolean validateStatus)
        {
            int idCommunity = View.IdCommunity;

            try
            {
                int idModule = (dto.Type == CallForPaperType.CallForBids) ? CallService.ServiceModuleID() : RequestService.ServiceModuleID();

                if (dto.Type == CallForPaperType.RequestForMembership && dto.EndDate.HasValue && dto.StartDate >= dto.EndDate.Value)
                {
                    View.DisplayDateError(dto.StartDate, dto.EndDate.Value);
                }
                else if (dto.Type == CallForPaperType.CallForBids && dto.EndDate.HasValue && dto.StartDate >= dto.EndDate.Value && ((dtoCall)dto).EndEvaluationOn.HasValue && dto.EndDate.Value >= ((dtoCall)dto).EndEvaluationOn.Value)
                {
                    View.DisplayDateError(CallForPaperType.CallForBids);
                }
                else if (dto.Type == CallForPaperType.CallForBids && dto.EndDate.HasValue && dto.StartDate >= dto.EndDate.Value)
                {
                    View.DisplayDateError(dto.StartDate, dto.EndDate.Value);
                }
                else if (dto.Type == CallForPaperType.CallForBids && dto.EndDate.HasValue && ((dtoCall)dto).EndEvaluationOn.HasValue && dto.EndDate.Value >= ((dtoCall)dto).EndEvaluationOn.Value)
                {
                    View.DisplayEvaluationDateError(dto.EndDate.Value, ((dtoCall)dto).EndEvaluationOn.Value);
                }
                else
                {
                    Boolean stepsToComplete = false;
                    List <lm.Comol.Core.Wizard.NavigableWizardItem <WizardCallStep> > wizardSteps = null;
                    BaseForPaper          call        = null;
                    List <WizardCallStep> skipedSteps = new List <WizardCallStep>();;
                    long    idCall        = dto.Id;
                    Boolean hasSubmission = false;
                    if (idCall > 0)
                    {
                        hasSubmission = CallService.CallHasSubmissions(idCall);
                    }
                    if (dto.Status > CallForPaperStatus.Draft && idCall == 0)
                    {
                        dto.Status         = CallForPaperStatus.Draft;
                        stepsToComplete    = true;
                        View.CurrentStatus = dto.Status;
                    }
                    else if (dto.Status > CallForPaperStatus.Draft && idCall > 0)
                    {
                        wizardSteps = CallService.GetAvailableSteps(idCall, WizardCallStep.GeneralSettings, View.CallType);
                        skipedSteps = CallService.GetSkippedSteps(wizardSteps, idCall, View.CallType);

                        stepsToComplete = (skipedSteps.Count > 0);

                        if (stepsToComplete && !hasSubmission)
                        {
                            dto.Status         = CallForPaperStatus.Draft;
                            View.CurrentStatus = dto.Status;
                        }
                    }


                    if (dto.Type == CallForPaperType.CallForBids)
                    {
                        call = CallService.SaveCallSettings((dtoCall)dto, idCommunity, validateStatus);
                    }
                    else
                    {
                        call = RequestService.SaveCallSettings((dtoRequest)dto, idCommunity, validateStatus, submitterName);
                    }
                    if (call != null)
                    {
                        idCall = call.Id;
                        RefreshCallName(View.CurrentAction, dto.Name, idCommunity);
                    }
                    View.IdCall = idCall;
                    if (dto.Type == CallForPaperType.CallForBids)
                    {
                        View.SendUserAction(idCommunity, idModule, idCall, (View.CurrentAction == CallStandardAction.Add) ? ModuleCallForPaper.ActionType.AddCallSettings : ModuleCallForPaper.ActionType.SaveCallSettings);
                    }
                    else
                    {
                        View.SendUserAction(idCommunity, idModule, idCall, (View.CurrentAction == CallStandardAction.Add) ? ModuleRequestForMembership.ActionType.AddCallSettings : ModuleRequestForMembership.ActionType.SaveCallSettings);
                    }
                    if (wizardSteps == null)
                    {
                        wizardSteps = CallService.GetAvailableSteps(idCall, WizardCallStep.GeneralSettings, call.Type);
                    }

                    if (stepsToComplete && skipedSteps.Count > 0)
                    {
                        View.DisplaySkippedRequiredSteps(skipedSteps);
                    }
                    else if (stepsToComplete && wizardSteps.Count > 0)
                    {
                        View.DisplaySkippedRequiredSteps(wizardSteps.Where(ws => ws.Status == Core.Wizard.WizardItemStatus.error || ws.Status == Core.Wizard.WizardItemStatus.disabled).Select(ws => ws.Id).ToList());
                    }
                    else if (call != null)
                    {
                        View.DisplaySettingsSaved();
                    }
                    if (View.InvalidStatusFound)
                    {
                        View.InvalidStatusFound = false;
                        View.LoadStatus(CallService.GetAvailableStatus(idCall), dto.Status);
                        dto = CallService.GetDtoBaseCall(idCall);
                        View.LoadCall(dto);
                        if (dto.Type == CallForPaperType.CallForBids)
                        {
                            View.LoadEvaluationSettings(CallService.GetEvaluationSettings(idCall, allowUseOfDss));
                        }
                    }
                    else
                    {
                        View.LoadStatus(CallService.GetAvailableStatus(idCall), dto.Status);
                    }

                    View.LoadWizardSteps(idCall, dto.Type, idCommunity, wizardSteps);
                }
            }
            catch (SkipRequiredSteps exc) {
                View.DisplaySkippedRequiredSteps(exc.Steps);
            }
            catch (CallForPaperInvalidStatus ex)
            {
                View.InvalidStatusFound = true;
                switch (dto.Status)
                {
                case CallForPaperStatus.Draft:
                    if (dto.StartDate >= DateTime.Now)
                    {
                        View.CurrentStatus = (!dto.EndDate.HasValue || (dto.EndDate.HasValue && dto.EndDate.Value <= DateTime.Now)) ? CallForPaperStatus.SubmissionOpened: CallForPaperStatus.SubmissionClosed;
                    }
                    else
                    {
                        View.CurrentStatus = CallForPaperStatus.SubmissionOpened;
                    }
                    break;
                }
                View.LoadInvalidStatus(dto.Status, dto.EndDate);
                RefreshCallName(View.CurrentAction, dto.Name, idCommunity);
            }
        }