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());
     }
 }
Esempio n. 3
0
 public void UpdateArticle(int id, DetailsModel item)
 {
     _articleService.Update(MapperTools.MapTo <DetailsModel, ArticleBl>(item));
 }
Esempio n. 4
0
 public void CreateArticle(DetailsModel item)
 {
     item.DateTime = DateTime.Now;
     item.AuthorId = 1;
     _articleService.Add(MapperTools.MapTo <DetailsModel, ArticleBl>(item));
 }
Esempio n. 5
0
        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));
        }