public ActionResult Details(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Map map = m_repo.GetMap(id.Value);

            if (map == null)
            {
                return(HttpNotFound());
            }

            ViewBag.MapComponents = m_repo.GetMapComponents(map.Id);

            var crossTypes = m_repo.GetCrossTypes().Where(t => t.GenusId == map.GenusId && t.Retired == false);

            ViewBag.CrossTypes = new SelectList(crossTypes, "Id", "Name");
            map.Questions      = map.Questions.OrderBy(q => q.Order).ToList();
            map.MapComponents  = map.MapComponents.OrderBy(t => t.Row).ThenBy(t => t.PlantNum).ToList();
            return(View(map));
        }
        public ActionResult IndexByGenus(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            var crossTypes = m_repo.GetCrossTypes().Where(c => c.GenusId == id);

            if (crossTypes.IsNullOrEmpty())
            {
                return(RedirectToAction("Create"));
            }
            return(View(crossTypes.ToList()));
        }
        private void SetViewBagForPlant(AccessionViewModel accession)
        {
            // TODO: use accession unit of work methods

            IEnumerable <SelectListItem> crossTypes = m_repo
                                                      .GetCrossTypes()
                                                      .Where(c => !c.Retired && c.GenusId == accession.FamilyGenusId || c.Id == accession.FamilyCrossTypeId)
                                                      .Select(c => new SelectListItem()
            {
                Value    = c.Id.ToString(),
                Text     = c.Name,
                Disabled = c.Retired
            }).OrderBy(t => t.Text);

            ViewBag.CrossTypeId = crossTypes;
        }
예제 #4
0
        public IEnumerable <SelectListItem> GetCrossTypesList(int genusId)
        {
            var items = u_repo.GetCrossTypes().Where(t => t.GenusId == genusId && t.Retired == false);

            return(items.ToSelectList(t => t.Id, t => t.Name).OrderBy(t => t.Text));
        }