/// <summary>
        /// Updates existed answer set with new data.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="selectionAnswerSetId">The selection answer set identifier.</param>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public async Task <ServiceActionResult <SelectionAnswerSetUpdateResult, SelectionAnswerSetResponseDto> > Update(
            int customerId,
            Guid selectionAnswerSetId,
            UpdateSelectionAnswerSetRequestDto model
            )
        {
            var answerSet = Mapper.Map <SelectionAnswerSet>(model);

            answerSet.Id = selectionAnswerSetId;

            answerSet.Tags = await tagsService.BuildTagsList(customerId, model.Tags);

            var selectionAnswerChoices = model.SelectionAnswerChoices.ToList();

            foreach (var answerDto in selectionAnswerChoices)
            {
                var answer = await this.MapSelectionAnswerChoice(answerDto, selectionAnswerChoices);

                answerSet.SelectionAnswerChoices.Add(answer);
            }

            var result = await this.selectionAnswerSetService.Update(customerId, selectionAnswerSetId, answerSet);

            if (result.Status != SelectionAnswerSetUpdateResult.Success)
            {
                return(result.Clone <SelectionAnswerSetResponseDto>());
            }

            await UpdateCachedLists(customerId, result.Content);

            return(result.CloneWithMapping(new SelectionAnswerSetResponseDto()));
        }
        public async Task <IHttpActionResult> UpdateSelectionAnswerSet(
            int customerId,
            Guid selectionAnswerSetId,
            UpdateSelectionAnswerSetRequestDto model
            )
        {
            var result = await selectionAnswerSetHelper.Update(customerId, selectionAnswerSetId, model);

            switch (result.Status)
            {
            case SelectionAnswerSetUpdateResult.NotFound:
                return(Content(
                           HttpStatusCode.NotFound,
                           new ErrorResponseDto()
                {
                    Error = ErrorCode.InvalidRequest,
                    Message = ErrorCode.InvalidRequest.Description(),
                    Details = GlobalStrings.SelectionAnswerSet_NotFoundError
                }));

            case SelectionAnswerSetUpdateResult.IncorrectAnswerId:
                return(Content(
                           HttpStatusCode.BadRequest,
                           new ErrorResponseDto()
                {
                    Error = ErrorCode.InvalidRequest,
                    Message = ErrorCode.InvalidRequest.Description(),
                    Details = GlobalStrings.SelectionAnswerSet_IncorrectAnswerChoiceId
                }));

            default:
                return(StatusCode(HttpStatusCode.NoContent));
            }
        }
示例#3
0
        /// <summary>
        /// Updates the selection answer set.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public Task UpdateSelectionAnswerSet(UpdateSelectionAnswerSetRequestDto request, int customerId, string token)
        {
            var url = string.Format("api/{0}/answer-sets/selection/{1}", customerId, request.Id);

            return(apiClient.SendRequestAsync(url, request, Method.PUT, null, token));
        }
 /// <summary>
 /// Updates the selection answer set.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="customerId">The customer identifier.</param>
 /// <param name="token">The token.</param>
 /// <returns></returns>
 public Task UpdateSelectionAnswerSet(UpdateSelectionAnswerSetRequestDto request, int customerId, string token)
 {
     return(healthLibraryDataProvider.UpdateSelectionAnswerSet(request, customerId, token));
 }