示例#1
0
        public async Task <IActionResult> Edit(int id)
        {
            DataResult <GenusModel> result = await _genusService.GetGenusById(id);

            ViewBag.Families = new SelectList(
                (await _familyRepository.GetAll()).OrderBy(e => e.Denomination),
                nameof(Genus.Id),
                nameof(Genus.Denomination));

            if (result.Success)
            {
                return(View("Edit", result.Data));
            }

            return(RedirectToAction("Error", "Error", new { result.ErrorCode, modelName = nameof(Genus) }));
        }
        public List <FamilyDto> GetAll(bool getOnlyActive)
        {
            List <FamilyDto> result = new List <FamilyDto>();

            try
            {
                if (!getOnlyActive)
                {
                    result = familyRepository.GetAll().Select(c => new FamilyDto(c)).ToList();
                }
                else
                {
                    result = familyRepository.GetAll().Where(c => c.IsActive).Select(c => new FamilyDto(c)).ToList();
                }
                return(result);
            }
            catch (Exception ex)
            {
                return(new List <FamilyDto>());
            }
        }
示例#3
0
 public IEnumerable <Family> GetAll()
 {
     return(_familyRepository.GetAll());
 }
 public IQueryable <Family> GetFamilys()
 {
     return(_repository.GetAll());
 }
示例#5
0
 public ActionResult <IEnumerable <Family> > GetFamilies()
 {
     return(_familyRepository.GetAll().ToList());
 }
示例#6
0
 public FamilyQuery(IFamilyRepository familyRepository)
 {
     Field <ListGraphType <FamilyType> >(
         "families",
         resolve: c => familyRepository.GetAll());
 }