public ActionResult Update(PostUpdateInput updateInput) { string postId = VerbosifyId <Post>(updateInput.Id); //if (!_permissionManager.DoesExist<Post>(postId)) //{ // return HttpNotFound(); //} //if (!_userContext.HasGroupPermission<Post>(PermissionNames.UpdatePost, postId)) //{ // return new HttpUnauthorizedResult(); //} if (ModelState.IsValid) { _messageBus.Send( new PostUpdateCommand { Id = postId, Subject = updateInput.Subject, Message = updateInput.Message, PostType = updateInput.PostType, UserId = _userContext.GetAuthenticatedUserId(), MediaResources = updateInput.MediaResources }); } else { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } dynamic viewModel = new ExpandoObject(); viewModel.Post = updateInput; return(RestfulResult( viewModel, "posts", "update")); }
public ActionResult Create(PostUpdateInput createInput) { var actualGroupId = createInput.GroupType + "/" + createInput.GroupId; //if (!_userContext.HasUserProjectPermission(PermissionNames.CreatePost)) //{ // return new HttpUnauthorizedResult(); //} if (ModelState.IsValid) { var key = string.IsNullOrWhiteSpace(createInput.Key) ? Guid.NewGuid().ToString() : createInput.Key; _messageBus.Send( new PostCreateCommand() { Key = key, Subject = createInput.Subject, Message = createInput.Message, PostType = createInput.PostType, UserId = _userContext.GetAuthenticatedUserId(), GroupId = actualGroupId, MediaResources = createInput.MediaResources }); } else { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } dynamic viewModel = new ExpandoObject(); viewModel.Post = createInput; return(RestfulResult( viewModel, "posts", "create")); }
public ActionResult Create(PostUpdateInput createInput) { var actualGroupId = createInput.GroupType + "/" + createInput.GroupId; //if (!_userContext.HasUserProjectPermission(PermissionNames.CreatePost)) //{ // return new HttpUnauthorizedResult(); //} if (ModelState.IsValid) { var key = string.IsNullOrWhiteSpace(createInput.Key) ? Guid.NewGuid().ToString() : createInput.Key; _messageBus.Send( new PostCreateCommand() { Key = key, Subject = createInput.Subject, Message = createInput.Message, PostType = createInput.PostType, UserId = _userContext.GetAuthenticatedUserId(), GroupId = actualGroupId, MediaResources = createInput.MediaResources }); } else { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } dynamic viewModel = new ExpandoObject(); viewModel.Post = createInput; return RestfulResult( viewModel, "posts", "create"); }
public ActionResult Update(PostUpdateInput updateInput) { string postId = VerbosifyId<Post>(updateInput.Id); //if (!_permissionManager.DoesExist<Post>(postId)) //{ // return HttpNotFound(); //} //if (!_userContext.HasGroupPermission<Post>(PermissionNames.UpdatePost, postId)) //{ // return new HttpUnauthorizedResult(); //} if (ModelState.IsValid) { _messageBus.Send( new PostUpdateCommand { Id = postId, Subject = updateInput.Subject, Message = updateInput.Message, PostType = updateInput.PostType, UserId = _userContext.GetAuthenticatedUserId(), MediaResources = updateInput.MediaResources }); } else { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } dynamic viewModel = new ExpandoObject(); viewModel.Post = updateInput; return RestfulResult( viewModel, "posts", "update"); }