public ActionResult CloseRequest(int id) { var request = _requestRepository.Find(r => r.RequestId == id).FirstOrDefault(); var adminResponse = Request.Params["reason"]; var requestDecision = Request.Params["decision"]; if (requestDecision == "Yes") { request.RequestAccepted = true; } request.RequestClosed = true; request.AdminResponse = adminResponse; request.AdminUserId = User.Identity.GetUserId(); var userNotification = CreateUserNotification(request); var createNotificationModel = new BLLUserNotificationTypes(userNotification, _unitOfWork); createNotificationModel.CreateUserNotification(); //want to move this out into a deletionRequest class _unitOfWork.DeletionRequests.Update(request); _unitOfWork.Complete(); if (requestDecision == "Yes") { return(RedirectToAction("Delete", "Feed", new { feedId = request.FeedId, requestId = request.RequestId })); } var redirectUrl = new UrlHelper(Request.RequestContext).Action("Requests"); return(Json(new { Url = redirectUrl })); }
public ActionResult Create() { var currentUserId = User.Identity.GetUserId(); var postIdString = Request.Params["postId"]; int.TryParse(postIdString, out int postId); var post = _postRepository.Find(p => p.PostId == postId).FirstOrDefault(); var comment = new Comment { PostId = postId, CommentText = Request.Params["commentText"], UserId = currentUserId, CreatedOn = DateTime.Now, Post = post }; var createComment = new Comments(_commentRepository, _unitOfWork, _postRepository); createComment.CreateNewComment(comment); var userNotification = CreateUserNotification(comment); var notification = new BLLUserNotificationTypes(userNotification, _unitOfWork); notification.CreateUserNotification(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("Details", "Post", new { id = postId }); return(Json(new { Url = redirectUrl })); }
public ActionResult DeleteFeedRequest(int id) { var request = new DeletionRequest { FeedId = id, UserId = User.Identity.GetUserId(), ReasonForDeletion = Request.Params["reason"], RequestClosed = false, AdminResponse = "" }; var deletionRequest = new DeletionRequests(_deletionRequestRepository, _unitOfWork); var isCreated = deletionRequest.TryCreateRequest(request); if (isCreated) { var userNotification = CreateUserNotification(request); var notification = new BLLUserNotificationTypes(userNotification, _unitOfWork); notification.CreateUserNotification(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("Details", "Feed", new { id }); return(Json(new { Url = redirectUrl })); } return(HttpNotFound()); }
public ActionResult Create() { var currentUserId = User.Identity.GetUserId(); var image = CreateLocalImage(Request, currentUserId); var feedIdString = Request.Params["feedId"]; int.TryParse(feedIdString, out int feedId); if (feedId == 0) { return(HttpNotFound()); } var feed = _feedRepository.Find(f => f.FeedId == feedId).FirstOrDefault(); var createPost = new Posts(_feedRepository, _postRepository, _unitOfWork); var post = new Post { FeedId = feedId, ImageId = image.ImageId, PostDate = DateTime.Now, UserId = currentUserId, Description = Request.Params["textInput"], Feed = feed }; var postCreated = createPost.TryCreatePost(post); if (postCreated) { var userNotification = CreateUserNotification(post); var notification = new BLLUserNotificationTypes(userNotification, _unitOfWork); notification.CreateUserNotification(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("Details", "Feed", new { id = feedId }); return(Json(new { Url = redirectUrl })); } return(HttpNotFound()); }