[ValidateAntiForgeryToken] // Moze se zabraniti preko [Authorize] public async Task <ActionResult> Objavi(ArticleModel articleModel, string userId) { if (ModelState.IsValid) { byte[] img = articleModel.Image.ToByteArray(); AppUser author = await UserManager.FindByIdAsync(userId); if (string.IsNullOrEmpty(author.FirstName) || string.IsNullOrEmpty(author.LastName)) { ModelState.AddModelError("", "Morate ažurirati ime ili prezime da biste objavili artikal!"); return(View(articleModel)); } Article article = new Article { Title = articleModel.Title, Text = articleModel.Text, Image = img, Author = author, Category = articleModel.Category, DatePublished = DateTime.Now }; //Context.Articles.Add(article); //await Context.SaveChangesAsync(); await ArticleManager.CreateArticleAsync(article); ViewBag.PostSuccess = "Artikal uspešno objavljen!"; } return(View(articleModel)); }