public ActionResult <QuestionnaireListResponse> Post([FromBody] QuestionnaireListRequest value) { //Instantiate database using var db = new DbModel(); //Creation of response object var result = new QuestionnaireListResponse { //Select to database where Questionnaires do have required UserId Questionnair = db.Questionnaires .Where(d => d.UserId == value.Questionnaire.UserId) .Select(d => new QuestionnaireListResponse.QuestionnaireList { //Filling up response object with data from database EndDate = d.EndDate, IsEvaluated = d.IsEvaluated, IsPublished = d.IsPublished, Name = d.Name, QuestionnaireId = d.QuestionnaireId, StartDate = d.StartDate, UserId = d.UserId }) .ToList() }; //If there are no values to return if (result.Questionnair.Count == 0) { result = new QuestionnaireListResponse { Questionnair = new List <QuestionnaireListResponse.QuestionnaireList>() }; } return(Ok(result)); }
public async Task <QuestionnaireListResponse> LoadDotazniky(int userID) { var apiForm = Configuration["url"]; QuestionnaireListResponse response = await _httlClient.PostJsonAsync <QuestionnaireListResponse>( apiForm + "api/Questionnaire/List", new QuestionnaireListRequest() { Questionnaire = new QuestionnaireListRequest.QuestionnaireList() { UserId = userID } }); return(response); }