Exemple #1
0
        public IActionResult Index(List <int?> humanIds)
        {
            //HttpContext.Response.StatusCode = 417;
            //var address = HttpContext.Request.Host;
            // if no ID value given in url
            if (humanIds.Count == 0)
            {
                var humans     = _repository.GetAllHumans();
                var viewModels = new List <HumanIndexViewModel>();

                foreach (var human in humans)
                {
                    var humanModel = new HumanIndexViewModel();
                    humanModel.Human = human;
                    viewModels.Add(humanModel);
                }
                return(View(viewModels));
            }
            else
            {
                var viewModels = new List <HumanIndexViewModel>();

                foreach (int id in humanIds)
                {
                    var humanModel = new HumanIndexViewModel();
                    humanModel.Human = _repository.GetHuman(id)[0];
                    viewModels.Add(humanModel);
                }

                return(View(viewModels));
            }
        }
Exemple #2
0
        public IActionResult HumanDelete(int humanId)
        {
            _repository.DeleteHuman(humanId);
            var humans     = _repository.GetAllHumans();
            var viewModels = new List <HumanIndexViewModel>();

            foreach (var human in humans)
            {
                var humanModel = new HumanIndexViewModel();
                humanModel.Human = human;
                viewModels.Add(humanModel);
            }
            return(View(viewModels));
        }
Exemple #3
0
        public IActionResult HumanModify(int humanId, string firstName, string lastName, int age, bool isSick, string gender, int countryId)
        {
            _repository.ModifyHuman(humanId, firstName, lastName, age, isSick, gender, countryId);
            var humans     = _repository.GetAllHumans();
            var viewModels = new List <HumanIndexViewModel>();

            foreach (var human in humans)
            {
                var humanModel = new HumanIndexViewModel();
                humanModel.Human = human;
                viewModels.Add(humanModel);
            }
            return(View(viewModels));
        }