Beispiel #1
0
        public void DeleteSelection(int genotypeId)
        {
            var genotype = u_repo.GetGenotype(genotypeId);

            if (genotype == null)
            {
                throw new ArgumentNullException();
            }

            //Check if the genotype belongs to anything

            if (genotype.IsBase ||
                genotype.FemaleofFamilies.Any() ||
                genotype.MaleofFamilies.Any() ||
                genotype.MapComponents.HasAny(m => m.isSeedling == true) ||
                u_repo.GetCrossPlans(
                    c => c.MaleParentId == genotype.Id ||
                    c.FemaleParentId == genotype.Id).Any())
            {
                throw new AccessionException("Selection is referenced in the DB");
            }
            else
            {
                u_repo.DeleteGenotypeWithRelated(genotype);
            }
        }
Beispiel #2
0
        public IEnumerable <SelectListItem> GetYears(string selectedYear, int genusId)
        {
            int yearVal = DateTime.Now.Year;

            int.TryParse(selectedYear, out yearVal);

            int currentYear = DateTime.Now.Year - 2;
            var items       = Enumerable.Range(currentYear, 5).Select(t => t.ToString()).ToList();
            var pastItems   = u_repo.GetCrossPlans(t => t.GenusId == genusId).Select(t => t.Year).Distinct().ToList();
            var allItems    = items.Union(pastItems).Distinct();

            return(allItems.Select(t => new SelectListItem
            {
                Text = t,
                Value = t,
                Selected = (t == yearVal.ToString())
            }).OrderByDescending(t => t.Value));
        }