public ActionResult Index(int?pageSize, int?genotypeId, string filter, int page = 1, string messageResult = "")
        {
            int    defaultPage       = 1;
            int    baseIdResult      = 0;
            int    genotypeIdResult  = 0;
            bool   successfullResult = true;
            string filterResult      = filter;

            if (!pageSize.HasValue)
            {
                if (SessionManager.SessionPageSize.HasValue)
                {
                    pageSize = SessionManager.SessionPageSize;
                }
                else
                {
                    pageSize = Properties.Settings.Default.PageSize;
                }
            }
            SetPageSizeViewBag();
            SessionManager.SessionPageSize = pageSize.Value;
            int genusId = SessionManager.GetGenusId().Value;

            IPagedList <AccessionIndexViewModel> pageOfAccessions = null;

            try
            {
                pageOfAccessions = a_repo.GetPageInIndex(pageSize.Value, genotypeId, filter, page, genusId);
            }
            catch (SearchException e)
            {
                successfullResult = false;
                messageResult     = e.Message;
            }

            if (successfullResult == false)
            {
                try
                {
                    pageOfAccessions = a_repo.GetPageInIndex(pageSize.Value, defaultPage, genusId);
                }
                catch (SearchException)
                {
                    return(RedirectToAction("Create"));
                    //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
            }

            Genotype genotypeSearched = null;

            if (!genotypeId.HasValue && !filter.IsNullOrWhiteSpace())
            {
                genotypeSearched = m_repo.GetGenotypes(filter, genusId, 1).FirstOrDefault();
            }
            else if (genotypeId.HasValue)
            {
                genotypeSearched = m_repo.GetGenotype(genotypeId.Value);
            }

            if (genotypeSearched != null)
            {
                successfullResult = true;
                genotypeIdResult  = genotypeSearched.Id;
                if (genotypeSearched.Family.BaseGenotypeId.HasValue && pageOfAccessions.HasAny(t => t.Id == genotypeSearched.Family.BaseGenotypeId))
                {
                    baseIdResult = genotypeSearched.Family.BaseGenotypeId.Value;
                }
                else
                {
                    baseIdResult = genotypeSearched.Id;
                }
            }

            ViewBag.GenusId            = genusId;
            ViewBag.GenotypeId         = genotypeIdResult;
            ViewBag.BaseId             = baseIdResult;
            ViewBag.SuccessfulSearch   = successfullResult;
            ViewBag.Filter             = filter;
            ViewBag.SearchErrorMessage = messageResult;
            ViewBag.PageSize           = pageSize.Value.ToString();
            ViewBag.CurrentDate        = DateTime.Now;

            return(View(pageOfAccessions));
        }