コード例 #1
0
        public ActionResult Create([FromForm] Post post, string id)
        {
            try
            {
                post.CreationTime = DateTime.Now;
                _postRepository.CreatePost(post);

                Wall wall;
                if (post.CircleId == null)
                {
                    wall = _wallRepository.GetWallByUserId(post.OwnerId);
                }

                else
                {
                    wall = _wallRepository.GetWallByCircleId(post.CircleId);
                }

                wall.Posts.Add(post.PostId);

                _wallRepository.Update(wall);

                return(RedirectToAction("Details", "Post", new { @id = post.PostId }));
            }
            catch
            {
                return(RedirectToAction("Details", "Post", new { @id = post.PostId }));
            }
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: TroelsBleicken/DAB3
        // GET: User/Details/5
        public ActionResult Details(string id)
        {
            ViewData["userlist"] = _userRepository.GetUsers();

            var wall = _wallRepository.GetWallByUserId(id);

            if (wall == null)
            {
                wall = new Wall {
                    User = id
                };
                _wallRepository.AddWall(wall);
            }


            ViewData["wall"] = wall;
            var posts = new List <Post>();

            if (wall != null)
            {
                foreach (var post in wall.Posts)
                {
                    posts.Add(_postRepository.GetPost(post));
                }
            }

            ViewData["posts"] = posts;

            return(View(_userRepository.GetUser(id)));
        }
コード例 #3
0
        // GET: Wall/Details/5
        public ActionResult Details(string id)
        {
            var wall = _wallRepository.GetWallById(id);

            if (wall != null)
            {
                return(View(wall));
            }

            wall = _wallRepository.GetWallByUserId(id);
            if (wall != null)
            {
                return(View(wall));
            }

            wall = new Wall {
                User = id
            };
            _wallRepository.AddWall(wall);
            return(View(wall));
        }