示例#1
0
        public async Task <IActionResult> GetGenders()
        {
            var result = await _genderBusiness.GetAllGenders();

            if (result.Any())
            {
                return(Ok(result));
            }

            return(NotFound());
        }
示例#2
0
        public async Task <IActionResult> GetAll()
        {
            try
            {
                var result = await _genderBusiness.GetAllGenders();

                if (result == null)
                {
                    return(NotFound());
                }

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#3
0
        private async Task SetDropDownList(string authorGenderName = null)
        {
            var genders = await _genderBusiness.GetAllGenders();

            IList <SelectListItem> selectListItems = new List <SelectListItem>();

            foreach (var genderDto in genders)
            {
                SelectListItem mySelectListItem = new SelectListItem
                {
                    Text     = genderDto.GenderType,
                    Value    = genderDto.Id.ToString(),
                    Selected = authorGenderName == genderDto.GenderType
                };
                selectListItems.Add(mySelectListItem);
            }

            ViewData["GenderList"] = selectListItems;
        }
        public async Task <IActionResult> Index()
        {
            var result = await _genderBusiness.GetAllGenders();

            return(View(result));
        }