public async Task <IActionResult> Add(AddDestinationViewModel model) { if (!string.IsNullOrWhiteSpace(model.Name) && await destinationService.ExistsAsync(model.Name)) { ModelState.AddModelError(nameof(model.Name), "Destination with the same name already exists."); } var invalidIds = await tagService.CheckForInvalidTagIds(model.SelectedTags); if (invalidIds.Any()) { ModelState.AddModelError(nameof(model.SelectedTags), $"Non-existing tags were selected. (Count: {invalidIds.Count})"); } if (!await regionService.ExistsAsync(model.RegionId)) { ModelState.AddModelError(nameof(model.RegionId), "Selected region does not exist."); } if (!ModelState.IsValid) { model.Tags = await GetTags(); model.Regions = await GetRegions(); return(View(model)); } await destinationService.AddAsync(model.Name, model.RegionId, model.SelectedTags); return(RedirectToAction(nameof(Add))); }