Example #1
0
        public virtual async Task <ActionResult <FeedbackDto> > Create([FromBody] FeedbackRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dto = await _feedbackService.CreateEntityAsync(request);

            if (dto == null)
            {
                return(StatusCode(500));
            }

            if (!string.IsNullOrEmpty(request.Email))
            {
                await _emailProvider.SendMessageOneToOne("*****@*****.**", "Thanks for feedback", request.Email,
                                                         "Hello, " + request.Name +
                                                         ". Thank you for taking the time to type feedback. " +
                                                         "Best regards, Watcher.", "");
            }

            return(CreatedAtAction("GetById", new { id = dto.Id }, dto));
        }