/// <summary> /// Checks if municipality code is valid or not. /// </summary> /// <returns></returns> public override void Validate(ModelStateDictionary modelState) { if (string.IsNullOrEmpty(Model)) { return; } var municipality = codeService.GetMunicipalityByCode(Model, true); if (municipality == null || !municipality.Id.IsAssigned()) { modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.CodeNotFound, Model)); } }
/// <summary> /// Gets a list of services related to defined municipality. /// </summary> /// <param name="code"></param> /// <param name="date"></param> /// <param name="page"></param> /// <returns></returns> protected IActionResult GetGuidPageByMunicipality(string code, [FromQuery] DateTime?date, [FromQuery] int page) { // check if municipality with given code exists var municipality = codeService.GetMunicipalityByCode(code, true); if (municipality == null || !municipality.Id.IsAssigned()) { return(NotFound(new VmError() { ErrorMessage = $"Municipality with code '{code}' not found." })); } return(Ok(serviceService.GetServicesByMunicipality(municipality.Id, date, page, pageSize))); }