Exemplo n.º 1
0
        public async Task <IActionResult> Create(PostsCreateModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }
            var currentUser = this.userManager.GetUserId(this.User);

            await this.postsService.Create(model.Content, model.UserId, currentUser, model.Title);

            return(this.Redirect($"/Profiles/Profile?id={model.UserId}"));
        }
Exemplo n.º 2
0
        public IActionResult Create(string id)
        {
            var currentUser = this.userManager.GetUserId(this.User);

            if (!this.postsService.GetFirstNameById(currentUser))
            {
                return(this.Redirect("/Profiles/Details"));
            }
            var userName  = this.postsService.GetNameById(id);
            var viewModel = new PostsCreateModel
            {
                UserId       = id,
                UserUserName = userName,
            };

            return(this.View(viewModel));
        }