public ActionResult Index(bool?firstLoad, int?genusId) { var user = User.Identity; ViewBag.IsAuth = user.IsAuthenticated; ViewBag.Name = user.Name; var sessionGenusId = SessionManager.GetGenusId(); if (firstLoad.HasValue && firstLoad.Value == false && !genusId.HasValue) { ViewBag.firstLoad = "false"; } if (genusId.HasValue && genusId.Value != sessionGenusId) { Genus genus = m_repo.GetGenus(genusId.Value); if (genus != null) { SessionManager.Genus = genus; sessionGenusId = genus.Id; } } ViewBag.genusId = new SelectList(m_repo.GetAllGenera(), "Id", "Value", sessionGenusId); ViewBag.SelectedGenusId = sessionGenusId.GetValueOrDefault(); return(View()); }
public ActionResult Create() { int genusId = SessionManager.GetGenusId().Value; List <Question> questions = m_repo.GetQuestions(q => q.Retired == false && q.GenusId == genusId).ToList(); var genus = m_repo.GetGenus(genusId); MapQuestionListViewModel model = MapQuestionViewModelTranslator.ToMapQuestionListViewModel(questions, genus, genus.DefaultPlantsInRep); var crossTypes = m_repo.GetCrossTypes().Where(t => t.GenusId == model.Map.GenusId && t.Retired == false); ViewBag.CrossTypes = new SelectList(crossTypes, "Id", "Name"); return(View(model)); }
// GET: Genus/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Genus genus = m_repo.GetGenus(id.Value); if (genus == null) { return(HttpNotFound()); } genus.Questions = genus.Questions.OrderBy(q => q.Order).ToList(); return(View(genus)); }
public void CreateMap(MapQuestionListViewModel model) { Map map = model.Map; if (map == null) { throw new MapException("Map is empty"); } IEnumerable <Question> selectedQuestions = model.Questions.Where(q => q.isChecked).ToQuestion(); IEnumerable <Question> mapQuestions = u_repo.GetQuestions(t => t.GenusId == model.Map.GenusId); map.Questions = mapQuestions.Intersect(selectedQuestions, new QuestionComparer()).ToList(); map.Genus = u_repo.GetGenus(map.GenusId); map.Retired = false; u_repo.SaveMap(map); Years year = new Years() { Map = map, MapId = map.Id, Year = map.PlantingYear }; u_repo.SaveYear(year); map.Years.Add(year); u_repo.SaveMap(map); }
public void SaveOrder(OrderViewModel order) { var newOrder = OrderViewModel.ToOrder(order); if (newOrder.Genus == null) { newOrder.Genus = u_repo.GetGenus(newOrder.GenusId); } if (newOrder.Location == null && newOrder.LocationId.HasValue) { newOrder.Location = u_repo.GetLocation(newOrder.LocationId.Value); } if (newOrder.Location != null && newOrder.Location.PrimaryContactId.HasValue) { newOrder.Grower = u_repo.GetGrower(newOrder.Location.PrimaryContactId.Value); } else if (newOrder.Grower == null) { newOrder.Grower = u_repo.GetGrower(newOrder.GrowerId); } u_repo.SaveOrder(newOrder); var newOrderVm = OrderViewModel.Create(newOrder); newOrderVm.CopyTo(order); }
private void GetDefaultValues(CrossPlan crossPlan, IPlantBreedingRepo repo) { if (crossPlan.Id > 0 && !crossPlan.GenotypeId.HasValue) { CrossPlan old = repo.GetCrossPlan(crossPlan.Id); if (!crossPlan.GenotypeId.HasValue) { crossPlan.GenotypeId = old.GenotypeId; } } if (crossPlan.FemaleParentId.HasValue && crossPlan.FemaleParent == null) { crossPlan.FemaleParent = repo.GetGenotype(crossPlan.FemaleParentId.Value); } if (crossPlan.MaleParentId.HasValue && crossPlan.MaleParent == null) { crossPlan.MaleParent = repo.GetGenotype(crossPlan.MaleParentId.Value); } if (crossPlan.OriginId.HasValue && crossPlan.OriginId == null) { crossPlan.Origin = repo.GetOrigin(crossPlan.OriginId.Value); } if (crossPlan.CrossTypeId.HasValue && crossPlan.CrossType == null) { crossPlan.CrossType = repo.GetCrossType(crossPlan.CrossTypeId.Value); } crossPlan.Genus = repo.GetGenus(crossPlan.GenusId); }
public ActionResult Details(int?id) { if (!id.HasValue) { return(RedirectToAction("Index")); } var genus = m_repo.GetGenus(id.Value); var traitViewModel = new TraitViewModel { Genus = genus, RetiredQuestions = genus.Questions.Where(t => t.Retired == true).OrderBy(t => t.Order), ActiveQuestions = genus.Questions.Where(t => t.Retired == false).OrderBy(t => t.Order) }; return(View(traitViewModel)); }
public CrossPlan GetNext(string year, int genusId) { Genus genus = u_repo.GetGenus(genusId); CrossPlan cross = new CrossPlan() { Genus = genus, GenusId = genus.Id, Year = year, DateCreated = System.DateTime.MinValue }; return(cross); }
public ActionResult Index(string year, int?genusId) { if (genusId == null) { genusId = SessionManager.GetGenusId().Value; } Genus genus = m_repo.GetGenus(genusId.Value); //TODO: check for valid year if (year.IsNullOrWhiteSpace()) { year = DateTime.Now.Year.ToString(); } CrossPlanIndexViewModel crossPlanIndex = c_repo.GetIndex(year, genusId.Value); ViewBag.GenusId = genusId; ViewBag.CrossTypes = crossPlanIndex.CrossTypes; return(View(crossPlanIndex)); }
public MapComponentFatesReportViewModel GetMapComponentFatesReportViewModel(int?genusId) { MapComponentFatesReportViewModel vm = new MapComponentFatesReportViewModel(); vm.MapYear = DateTime.Now.Year.ToString(); vm.MapIsSeedling = true; if (genusId.HasValue) { Genus genus = u_repo.GetGenus(genusId.Value); vm.GenusId = genus.Id; vm.GenusName = genus.Name; } return(vm); }