public async Task <IEnumerable <Order> > Get(OrderGetOptions options) { try { StringBuilder sql = new StringBuilder(); _logger.LogInformation("Try to create get orders sql query"); sql.AppendLine($@" select {"\"Id\""}, {"\"DeliveryId\""}, {"\"FullName\""}, {"\"Addres\""}, {"\"SpecialDate\""}, {"\"PaymentMethod\""} from {"\"Order\""} "); int conditionIndex = 0; if (options.Id.HasValue) { sql.AppendLine($"{(conditionIndex++ == 0 ? "where" : "and")} ({"\"Id\""} = @id)"); } if (options.Ids != null) { sql.AppendLine($"{(conditionIndex++ == 0 ? "where" : "and")} ({"\"Id\""} = any(@ids))"); } if (!string.IsNullOrEmpty(options.NormalizedSearch)) { sql.AppendLine($@" {(conditionIndex++ == 0 ? "where" : "and")} (lower({"\"FullName\""}) like lower(@NormalizedSearch)) "); } _logger.LogInformation($"Sql query successfully created:\n{sql.ToString()}"); _logger.LogInformation("Try to execute sql get orders query"); var result = await QueryAsync <Order>(sql.ToString(), options); _logger.LogInformation("Sql get orders query successfully executed"); return(result); } catch (Exception exception) { _logger.LogError(exception.Message); throw exception; } }
public virtual Task <Order> GetAsync(string orderId, OrderGetOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { return(this.GetEntityAsync(orderId, options, requestOptions, cancellationToken)); }
public virtual Order Get(string orderId, OrderGetOptions options = null, RequestOptions requestOptions = null) { return(this.GetEntity(orderId, options, requestOptions)); }
public virtual Task <Order> Get(string planId, OrderGetOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { return(GetEntity(planId, options, requestOptions, cancellationToken)); }
public async Task <IActionResult> Get([FromQuery] OrderGetOptions options) { return(Ok(await _service.Get(options))); }
public async Task <IEnumerable <Order> > Get(OrderGetOptions options) => await _dao.Get(options);