예제 #1
0
        public async Task <IActionResult> AddMessageToUser(string username, CreateMessageModel model)
        {
            try
            {
                await _timelineService.CreateMessage(model, username);
            }
            catch (UnknownUserException e)
            {
                return(BadRequest(new ErrorResponse(e)));
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> AddMessage(CreateMessageModel model)
        {
            try
            {
                await _timelineService.CreateMessage(model, User.GetUserID());
            }
            catch (UnknownUserException e)
            {
                return(BadRequest(new ErrorResponse(e)));
            }

            ViewData["messages"] = new List <string>
            {
                "Your message was recorded"
            };

            return(RedirectToAction(nameof(Timeline)));
        }