public ActionResult CreateArticle(CreateArticleVM model) { if (ModelState.IsValid) { this.repos.CreateArticle(model.BlogID, model.ThemeID, model.Title, model.Content, model.Tags); } return(RedirectToAction("Index", "Home")); }
public IActionResult OnPost(CreateArticleVM model) { Categories = new SelectList(_categoryApplication.GetAllForSearch(), "Id", "Name"); if (!ModelState.IsValid) { return(Page()); } var result = _articleApplication.Create(model); if (result.IsSucceeded) { return(RedirectToPage("Index")); } return(Page()); }
public OperationResult Create(CreateArticleVM command) { OperationResult result = new OperationResult(); if (_articleRepository.IsExist(a => a.Title == command.Title)) { return(result.Failed(ValidateMessage.IsDuplicatedName)); } var slug = command.Slug.Slugify(); var categorySlug = _categoryRepository.GetCategorySlugBy(command.CategoryId); var path = $"{categorySlug}/{slug}"; var pictureName = Uploader.ImageUploader(command.PictureName, path, null !); var article = new Article(command.Title, command.CategoryId, pictureName, command.PictureAlt, command.PictureTitle, command.PublishDate.ToGeorgianDateTime(), command.ShortDescription, command.Description, slug, command.Keywords, command.MetaDescription, command.CanonicalUrl); _articleRepository.Create(article); _articleRepository.SaveChanges(); return(result.Succeeded()); }