Exemplo n.º 1
0
        public IActionResult Compose(GroupViewModel model, int id)
        {
            var token = HttpContext.Request.Cookies["user-token"];

            var user = _profileRepository.GetUserByToken(token);


            if (ModelState.IsValid)
            {
                Post post = new Post
                {
                    Title     = model.Post.Title,
                    Text      = model.Post.Text,
                    AddedDate = DateTime.Now,
                    GroupId   = id,
                    UserId    = user.Id,
                };

                _profileRepository.CreatePost(post);

                return(RedirectToAction("index", new { id = id }));
            }

            return(View(model));
        }