public SearchResultDTO <Lib.Data.Insolvence.Rizeni> Hledat([FromUri] string dotaz = null, [FromUri] int?strana = null,
                                                                   [FromUri] int?razeni   = null)
        {
            strana = strana ?? 1;
            razeni = razeni ?? 0;

            if (strana < 1)
            {
                strana = 1;
            }
            if (strana * ApiV2Controller.DefaultResultPageSize > ApiV2Controller.MaxResultsFromES)
            {
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest, $"Hodnota 'strana' nemůže být větší než {ApiV2Controller.MaxResultsFromES / ApiV2Controller.DefaultResultPageSize}"));
            }

            Lib.Searching.InsolvenceSearchResult result = null;

            if (string.IsNullOrWhiteSpace(dotaz))
            {
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest, $"Hodnota dotaz chybí."));
            }

            bool isLimited = !(
                this.ApiAuth.ApiCall.UserRoles.Contains("novinar") ||
                this.ApiAuth.ApiCall.UserRoles.Contains("Admin") ||
                this.ApiAuth.ApiCall.UserRoles.Contains("KomercniLicence")
                );

            result = Lib.Data.Insolvence.Insolvence.SimpleSearch(dotaz, strana.Value,
                                                                 ApiV2Controller.DefaultResultPageSize, razeni.Value, false, isLimited);

            if (result.IsValid == false)
            {
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest, $"Špatně nastavená hodnota dotaz=[{dotaz}]"));
            }
            else
            {
                var filtered = result.ElasticResults.Hits
                               .Select(m => m.Source)
                               .ToArray();

                var ret = new SearchResultDTO <Lib.Data.Insolvence.Rizeni>(result.Total, result.Page, filtered);
                return(ret);
            }
        }
Beispiel #2
0
        public ActionResult Hledat(Lib.Searching.InsolvenceSearchResult model)
        {
            if (model == null || ModelState.IsValid == false)
            {
                return(View(new Lib.Searching.InsolvenceSearchResult()));
            }
            model.LimitedView = IsLimitedView();
            var res = Insolvence.SimpleSearch(model);

            Lib.Data.Audit.Add(
                Lib.Data.Audit.Operations.UserSearch
                , this.User?.Identity?.Name
                , this.Request.UserHostAddress
                , "Insolvence"
                , res.IsValid ? "valid" : "invalid"
                , res.Q, res.OrigQuery);

            return(View(res));
        }
Beispiel #3
0
 public InsolvenceIndexViewModel()
 {
     NoveFirmyVInsolvenci = new Lib.Searching.InsolvenceSearchResult();
     NoveOsobyVInsolvenci = new Lib.Searching.InsolvenceSearchResult();
 }