public IActionResult Create(UserFeedbackDTO userFeedbackDto)
 {
     try
     {
         // TODO Anonymous user logic
         UserFeedbackValidator.Validate(userFeedbackDto);
         var userFeedback = UserFeedbackMapper.DtoToObject(userFeedbackDto);
         return(Ok(_userFeedbackService.Create(userFeedback)));
     }
     catch (ArgumentException e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemple #2
0
 public static UserFeedback DtoToObject(UserFeedbackDTO dto)
 {
     return(new UserFeedback
     {
         Date = DateTime.Now,
         FeedbackVisibility = new FeedbackVisibility
         {
             IsAnonymous = dto.IsAnonymous,
             IsPublic = dto.IsPublic,
             IsPublished = dto.IsPublished
         },
         UserComment = dto.UserComment,
         PatientAccountId = dto.UserId
     });
 }
Exemple #3
0
 /// <summary>
 /// Validates the given <see cref="UserFeedbackDto"/> object.
 /// </summary>
 /// <param name="entity"> DTO to be validated </param>
 /// <exception cref="ValidationException">
 /// If comment is empty, or longer than <see cref="COMMENT_MAX_LEN"/>
 /// </exception>
 public static void Validate(UserFeedbackDTO entity)
 {
     IsCommentEmpty(entity.UserComment);
     IsCommentTooLong(entity.UserComment);
 }