public ActionResult Edit(int id = 0) { Article article = articlesRepository.Articles.Find(id); if (article == null) { return(HttpNotFound()); } ArticleEdit articleEdit = new ArticleEdit(); articleEdit.InjectFrom(article); return(View(articleEdit)); }
public ActionResult Edit(Category category, ArticleEdit articleEdit) { if (ModelState.IsValid) { Article article = articlesRepository.Articles.Find(articleEdit.Id); article.InjectFrom(articleEdit); articlesRepository.Entry(article).State = EntityState.Modified; articlesRepository.SaveChanges(); return(RedirectToAction("Index", new { category })); } return(View(articleEdit)); }
/// <summary> /// Transaction /// </summary> /// <param name="data"></param> /// <param name="action"></param> /// <returns>true/false</returns> public async Task <int> Transaction(ArticleEdit data, char action) { try { var val = await _adapterPattern.SingleTransaction <ArticleEdit, int>(data, "usp_Article_Transaction", action, DataConfiguration.instanceCore); return(val); } catch (Exception ex) { Logger.LogError(ex); return(0); } }
public async Task <IActionResult> OnGetAsync(string slug) { if (slug == null) { return(NotFound()); } var article = await _mediator.Send(new GetArticleQuery(slug)); if (article == null) { return(new ArticleNotFoundResult()); } Article = _mapper.Map <ArticleEdit>(article); return(Page()); }
public void CreateArticle(ArticleEdit article) { Article new_article = new Article() { Title = article.Title, Text = article.Text, ImgName = article.ImgName, DateTime = article.DateTime }; Db.Articles.Create(new_article); using (var db = new PeriodicalContext()) { var existedArticle = db.Articles.Where(e => e.Title == new_article.Title).FirstOrDefault(); var edition = db.Editions.Where(e => e.Name == article.EditionName).FirstOrDefault(); existedArticle.Edition = edition; edition.Articles.Add(existedArticle); db.SaveChanges(); } }
public async Task <int> Transaction(ArticleEdit data, char action) { return(await _articleDA.Transaction(data, action)); }
public void EditArticle(ArticleEdit article) { DeleteArticle(article.ArticleId); CreateArticle(article); }