Exemplo n.º 1
0
        private async Task <string> GetRouteParam(string first, string second, string third, RouteParams paramType)
        {
            ISlugService service = paramType == RouteParams.City
                                ? this.cityService
                                : paramType == RouteParams.Type
                                        ? (ISlugService)this.escortTypeService
                                        : paramType == RouteParams.Service
                                                ? this.serviceService
                                                : null;

            if (service == null)
            {
                throw new ArgumentException($"Unknown {nameof(paramType)}: {paramType}");
            }

            if (await service.IsSlugExists(first))
            {
                return(first);
            }
            if (await service.IsSlugExists(second))
            {
                return(second);
            }
            if (await service.IsSlugExists(third))
            {
                return(third);
            }

            return(string.Empty);
            // throw new ArgumentException($"Unkown route: {first}/{second}/{third}");
        }