// GET: Prosecutor
 public ActionResult Index()
 {
     if (CurrentUser != null)
     {
         try
         {
             List <ProsecutorViewModels> Prosecutors = prosecutorService.GetProsecutor(IsAuthenticatied ? CurrentUser.CourtID : null)
                                                       .Select(pros => new ProsecutorViewModels
             {
                 ID = pros.ID,
                 ProsecutionName = pros.ProsecutionName,
                 ProcecutoerName = pros.ProcecutoerName,
                 NationalID      = pros.NationalID
             }).ToList();
             return(View(Prosecutors));
         }
         catch (Exception ex)
         {
             return(ErrorPage(ex));
         }
     }
     else
     {
         return(RedirectTo(Url.Action("login", "User", new { returnUrl = "/" })).WithErrorMessages("تم الخروج بشكل تلقائى لعدم التفاعل اكثر من 15 دقيقة"));
     }
 }
        private OpenRollCreateViewModel PrepareViewModel(OpenRollViewModel OPenRoll = null)
        {
            if (OPenRoll == null)
            {
                OPenRoll = new OpenRollViewModel();
            }
            OpenRollCreateViewModel model = new OpenRollCreateViewModel()
            {
                ListCasesInRoll = RollService.GetRollCasesForOpening(OPenRoll.CircuitID, CurrentUser.ID)
                                  .Select(roll => new OpenRollViewModel
                {
                    SessionID         = roll.SessionID,
                    Order             = roll.Order,
                    CaseID            = roll.CaseID,
                    CaseStatus        = roll.CaseStatus,
                    OverAllNumber     = roll.OverAllNumber,
                    FirstLevelNumber  = roll.FirstLevelNumber,
                    SecondLevelNumber = roll.SecondLevelNumber,
                    MainCrime         = roll.MainCrime,
                    SecretaryID       = roll.SecretaryID,
                    RollID            = roll.RollID,
                    //CircuitID=roll.CircuitID,
                    //   rollStatus=roll.rollStatus,
                }).ToList(),
                //  SessionData = SessionService.GetSessionData(OPenRoll.CircuitID),
                Circuits = CircuitService.GetCircuitsBySecretairyID(CurrentUser.ID, CurrentUser.CourtID),

                OPenRoll    = OPenRoll,
                Prosecutors = ProsecutorService.GetProsecutor(CurrentUser.CourtID)
                              .Select(pros => new ProsecutorViewModels
                {
                    ID = pros.ID,
                    ProcecutoerName = pros.ProcecutoerName,
                }).ToList(),
                Halls = LookupService.GetCourtHalls(IsAuthenticatied ? CurrentUser.CourtID : null),
            };

            if (model.ListCasesInRoll.Count() != 0)
            {
                model.OPenRoll.RollID = model.ListCasesInRoll.Select(e => e.RollID).FirstOrDefault();
            }
            if (model.ListCasesInRoll.Any(e => e.Order == 0))
            {
                model.OPenRoll.rollStatus = RollStatus.NotSorted;
            }
            model.ListCasesInRoll = PrepareOrder(model.ListCasesInRoll);
            vw_SessionData SessionDate = new vw_SessionData();

            SessionDate.SessionDate     = DateTime.Now;
            model.SessionData           = SessionDate;
            model.OPenRoll.CourtID      = CurrentUser.CourtID;
            model.OPenRoll.CurentUserID = CurrentUser.ID;
            return(model);
        }