Exemplo n.º 1
0
        public HttpResponseMessage PostComment(CommentViewModel commentVM)
        {
            if (ModelState.IsValid)
            {
                string userName = User.Identity.Name;

                var user = userBLL.GetUserByUserName(userName);

                // Set Properties
                commentVM.UserId    = user.Id;
                commentVM.FirstName = user.FirstName;
                commentVM.LastName  = user.LastName;

                postBLL.AddComments(commentVM);

                // Send Notification using SignalR
                friendHub.Value.Clients.All.showUpdatedPost();

                return(Request.CreateResponse(HttpStatusCode.Created, commentVM));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }