public IActionResult Create(WantedPeopleFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Languages = this.GetLanguages();
                model.Countries = this.GetCountries();

                return(View(model));
            }

            var existingLanguages = this.bountyAdminService.AreLanguagesExisting(model.SelectedLanguages);
            var existingCountries = this.bountyAdminService.AreCountriesExisting(model.SelectedCountries);

            if (!existingLanguages || !existingCountries)
            {
                return(BadRequest("Unexisting language or country."));
            }

            try
            {
                this.bountyAdminService.CreateWantedPerson(
                    model.FirstName,
                    model.LastName,
                    model.Gender,
                    model.DateOfBirth,
                    model.PlaceOfBirth,
                    model.Reward,
                    model.Height,
                    model.Weight,
                    model.HairColor,
                    model.EyeColor,
                    model.PictureUrl,
                    model.SelectedCountries,
                    model.SelectedLanguages,
                    model.AllNames,
                    model.ScarsOrDistinguishingMarks);
            }
            catch (InvalidOperationException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            var wantedPersonId = this.bountyAdminService.GetLastWantedPerson();

            TempData.AddSuccessMessage("Person successfully added to the system, please specify charges for person created");

            return(RedirectToAction(nameof(AddCharge), new { id = wantedPersonId }));
        }
        public IActionResult Edit(int id, WantedPeopleFormViewModel model)
        {
            var exsitingPerson = this.wantedPeopleService.IsPersonExisting(id);

            if (!exsitingPerson)
            {
                return(BadRequest());
            }

            var selectedLanguages = model.SelectedLanguages;
            var selectedCountries = model.SelectedCountries;

            if (selectedCountries == null || selectedLanguages == null)
            {
                ModelState.AddModelError(string.Empty, "Please choose language and nationality! Refresh the page in order to see the old languages and nationalities!");
            }

            if (!ModelState.IsValid)
            {
                model.Languages = this.GetLanguages();
                model.Countries = this.GetCountries();

                return(View(model));
            }

            var existingLanguages = this.bountyAdminService.AreLanguagesExisting(model.SelectedLanguages);
            var existingCountries = this.bountyAdminService.AreCountriesExisting(model.SelectedCountries);

            if (!existingLanguages || !existingCountries)
            {
                return(BadRequest("Unexisting language or country."));
            }

            try
            {
                this.bountyAdminService.EditWantedPerson(
                    id,
                    model.FirstName,
                    model.LastName,
                    model.Gender,
                    model.DateOfBirth,
                    model.PlaceOfBirth,
                    model.Reward,
                    model.Height,
                    model.Weight,
                    model.HairColor,
                    model.EyeColor,
                    model.PictureUrl,
                    model.SelectedCountries,
                    model.SelectedLanguages,
                    model.AllNames,
                    model.ScarsOrDistinguishingMarks);
            }
            catch (InvalidOperationException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            TempData.AddSuccessMessage($"Person {model.FirstName} {model.LastName} successfully changed");

            return(RedirectToAction(nameof(Web.Controllers.WantedPeopleController.Index), WantedPeopleControllerName));
        }