public ActionResult ProjectFileUpload(vmForumAttachFilesToPost attachFileToPostViewModel)
        {
            try
            {
                int UserIDX = db_Accounts.GetUserIDX();

                // First this to do is get the post
                var project = db_EECIP.GetT_OE_PROJECTS_ByIDX(attachFileToPostViewModel.UploadPostId);
                if (project != null)
                {
                    // Check we get a valid post back and have some file
                    if (attachFileToPostViewModel.Files != null && attachFileToPostViewModel.Files.Any())
                    {
                        UploadProjectFiles(attachFileToPostViewModel.Files, UserIDX, project.PROJECT_IDX);
                        TempData["Success"] = "Upload success";
                    }
                    else
                    {
                        TempData["Error"] = "Please select a file";
                    }

                    return(RedirectToAction("ProjectDetails", "Dashboard", new { id = project.PROJECT_IDX }));
                }
                else
                {
                    TempData["Error"] = "Invalid post";
                }

                return(RedirectToAction("ShowTopic", "Forum", new { id = project.PROJECT_IDX }));
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Invalid post";
                return(RedirectToAction("Index", "Forum"));
            }
        }
Exemplo n.º 2
0
        public ActionResult PostFileUpload(vmForumAttachFilesToPost attachFileToPostViewModel)
        {
            try
            {
                int UserIDX = db_Accounts.GetUserIDX();

                // First this to do is get the post
                var post = db_Forum.GetPost_ByID(attachFileToPostViewModel.UploadPostId);
                if (post != null)
                {
                    // Check we get a valid post back and have some file
                    if (attachFileToPostViewModel.Files != null && attachFileToPostViewModel.Files.Any())
                    {
                        UPloadPostFiles(attachFileToPostViewModel.Files, UserIDX, post.Id);

                        TempData["Success"] = "Upload success";
                        return(RedirectToAction("ShowTopic", "Forum", new { id = post.Topic_Id }));
                    }
                    else
                    {
                        TempData["Error"] = "Please select a file";
                    }
                }
                else
                {
                    TempData["Error"] = "Invalid post";
                }

                return(RedirectToAction("ShowTopic", "Forum", new { id = post.Topic_Id }));
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Invalid post";
                return(RedirectToAction("Index", "Forum"));
            }
        }