public void SaveArticle(Article article)
 {
     if (article.ArticleID == 0)
     {
         context.Articles.Add(article);
     }
     else
     {
         Article dbEntry = context.Articles.Find(article.ArticleID);
         if (dbEntry != null)
         {
             dbEntry.ArticleID = article.ArticleID;
             dbEntry.Text = article.Text;
             dbEntry.Category = article.Category;
             dbEntry.CreatedDate = article.CreatedDate;
             dbEntry.Images = article.Images;
             dbEntry.Introduction = article.Introduction;
             dbEntry.KeyWords = article.KeyWords;
             dbEntry.Title = article.Title;
             dbEntry.User = article.User;
             dbEntry.Views = article.Views;
         }
     }
     context.SaveChanges();
 }
Example #2
0
 private void Update(Article article)
 {
     if(db.Exist(article.id) && db.Count(article.Slug) <= 1)
     {
         db.Update(article);
     }
 }
Example #3
0
 private Article Create(Article article)
 {
     if(db.Count(article.Slug) == 0)
     {
         return db.Create(article);
     }
     return null;
 }
Example #4
0
 public void Create(Article instance)
 {
     try
     {
         context.Entry(instance).State = EntityState.Added;
     }
     catch (Exception exception)
     {
         logger.Trace(exception.StackTrace);
         throw;
     }
 }
Example #5
0
        public void SaveArticle(Article Article)
        {
            if (Article.Id == 0)
            {

                _RArticle.Add(Article);
            }
            else
            {
                _uow.Entry(Article).State = EntityState.Modified;
            }
            _uow.SaveChanges();
        }
        public async Task <ActionResult> EditArticle(Guid Id)
        {
            Article model = null;

            using (EFArticleContext articleContext = new EFArticleContext())
            {
                model = await articleContext.FindByIdAsync(Id);
            }
            if (model != null)
            {
                model.TextArticle = Server.HtmlDecode(model.TextArticle);
                model.TextMain    = Server.HtmlDecode(model.TextMain);
            }
            else
            {
                model             = new Domain.Entities.Article();
                model.IsVisible   = true;
                model.DatePublish = DateTime.Now;
            }
            return(View(model));
        }
Example #7
0
        public ActionResult SaveArticle(string Title, string ShortDes, string LongDes, bool IsShow, string Tags,string metaDescription)
        {
            if (IsValidSessions())
            {

                TempData["result"] = "OK";
                Article Article = new Article();
                Article.IsShow = IsShow;
                Article.Title = Title;
                Article.ShortDes = ShortDes;
                Article.LongDes = LongDes;
                Article.Tags = Tags;
                Article.LanguageId = Convert.ToInt32(Session["Language"].ToString());
                Article.CreationDate = DateTime.Now;
                Article.metaDescription = metaDescription;

                _RArticle.SaveArticle(Article);
                TempData["Folder"] = Article.Id;
                TempData["result"] = "OK";
                TempData["Message"] = "عملیات با موفقیت انجام شد.";
                return Json(new { Idms = Article.Id }, JsonRequestBehavior.AllowGet);

            }
            else
                return RedirectToAction("Login", "Home");
        }
Example #8
0
 public void DeleteArticle(Article Article)
 {
     _RArticle.Remove(Article);
     _uow.SaveChanges();
 }