예제 #1
0
        public ActionResult AddPost(PostViewModel postViewModel)
        {
            var userId = User.Identity.GetUserId();
            var path   = FilesHandler.saveImage(postViewModel.picture, Server);

            if (postViewModel.picture == null || path != null)
            {
                PostViewModel.addPostFrom(userId, databaseEntities, path, postViewModel.content, postViewModel.albumID, postViewModel.group_id);
            }
            else
            {
                ModelState.AddModelError("imageError", "Something went wrong we were unable to save the photo");
            }

            switch (postViewModel.appLocation)
            {
            case "Profile":
                return(RedirectToAction("ShowMyProfile", "Profile"));

            case "Newsfeed":
                return(RedirectToAction("Index", "NewsFeed"));

            case "Groups":
                return(RedirectToAction("Show", "Groups"));

            default:
                return(Index());
            }
        }