Beispiel #1
0
        public async Task <IActionResult> Status([FromBody] RequestStatusRequest request, int id)
        {
            var req = await _requestsRepository.ChangeStatus(request, id);

            Response response;

            if (request.Status == RequestStatus.Resolved)
            {
                string text =
                    String.Format("Hello {0} {1},\r\n\r\nYour request has been resolved.\r\n\r\nKind regards, Debook.", req.User.FirstName, req.User.LastName);
                string htmlText =
                    String.Format("Hello {0} {1},<br /><br />Your request has been resolved.<br /><br />Kind regards, Debook.", req.User.FirstName, req.User.LastName);
                response = await _emailService.Send(text, "Request resolved", htmlText, req.User.Email);
            }
            else
            {
                string text =
                    String.Format("Hello {0} {1},\r\n\r\nYour request has been cancelled.\r\n\r\nKind regards, Debook.", req.User.FirstName, req.User.LastName);
                string htmlText =
                    String.Format("Hello {0} {1},<br /><br />Your request has been cancelled.<br /><br />Kind regards, Debook.", req.User.FirstName, req.User.LastName);
                response = await _emailService.Send(text, "Request cancelled", htmlText, req.User.Email);
            }

            if (response.StatusCode != System.Net.HttpStatusCode.Accepted)
            {
                return(StatusCode(StatusCodes.Status406NotAcceptable, new { Message = "Email sending failed." }));
            }

            return(NoContent());
        }