public async Task <IActionResult> SearchAsync([FromQuery] Client.ActivityInfoSearchQuery infoSearchQuery, CancellationToken cancellationToken) { if (infoSearchQuery == null) { var error = ServiceErrorResponses.InvalidQuery("ActivityInfoSearchQuery"); return(this.BadRequest(error)); } var modelQuery = ActivitySearchInfoQueryConverter.Convert(infoSearchQuery); var modelActivities = await activityRepository.SearchAsync(modelQuery, cancellationToken); var clientActivities = modelActivities.Select(ActivityConverter.Convert).ToList(); var clientActivityList = new ActivityList { Activities = clientActivities }; return(Ok(clientActivityList)); }
/// <summary> /// Переводит запрос активностей из клиентсокой модели в серверную /// </summary> /// <param name="clientQuery">Запрос задач в клиентской модели</param> /// <returns>Запрос задач в серверной модели</returns> public static Model.ActivityInfoSearchQuery Convert(Client.ActivityInfoSearchQuery clientQuery) { if (clientQuery == null) { throw new ArgumentNullException(nameof(clientQuery)); } var modelQuery = new Model.ActivityInfoSearchQuery { Tags = clientQuery.Tags, Experts = clientQuery.Experts, StartAt = clientQuery.StartAt, CreatedAt = clientQuery.CreatedAt, CreatedBy = clientQuery.CreatedBy, MaraphoneId = clientQuery.MaraphoneId, Limit = clientQuery.Limit, Offset = clientQuery.Offset }; return(modelQuery); }