public ActionResult Edit(int id, DetailsModel model) { try { // TODO: Add update logic here if (ModelState.IsValid) { _articleService.Update(MapperTools.MapTo <DetailsModel, ArticleBl>(model)); return(RedirectToAction("ListArticle")); } return(View(model)); } catch { return(View()); } }
public ActionResult Create(DetailsModel model) { try { // TODO: Add insert logic here if (ModelState.IsValid) { model.DateTime = DateTime.Now; model.AuthorId = 1; _articleService.Add(MapperTools.MapTo <DetailsModel, ArticleBl>(model)); string subject = "Creatr Article"; string to = "*****@*****.**"; string from = "*****@*****.**"; string body = model.Title; _emailService.SendSmpt(subject, body, from, to); return(RedirectToAction("ListArticle")); } return(View(model)); } catch { return(View()); } }
public void UpdateArticle(int id, DetailsModel item) { _articleService.Update(MapperTools.MapTo <DetailsModel, ArticleBl>(item)); }
public void CreateArticle(DetailsModel item) { item.DateTime = DateTime.Now; item.AuthorId = 1; _articleService.Add(MapperTools.MapTo <DetailsModel, ArticleBl>(item)); }
public DetailsModel GetArticle(int id) { var res = MapperTools.MapTo <ArticleBl, DetailsModel>(_articleService.GetById(id)); return(res); }
// GET: Article/Edit/5 public ActionResult Edit(int id) { var res = MapperTools.MapTo <ArticleBl, DetailsModel>(_articleService.GetById(id)); return(View(res)); }