示例#1
0
 public void CreateOrUpdate(Article model)
 {
     if (string.IsNullOrWhiteSpace(model.Summary))
     {
         var summaryLength = model.SummarySize > model.Content.Length ? model.Content.Length : model.SummarySize;
         model.Summary = model.Content.Substring(0, summaryLength);
     }
     if (!string.IsNullOrWhiteSpace(model.ArticleId))
     {
         _article.Update(model);
     }
     else
     {
         model.ArticleId = Helper.CreateGuidWithNoSplit();
         _article.Insert(model);
     }
 }
示例#2
0
 public bool CreateOrUpdate(Category model)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(model.CategoryId))
         {
             _category.Update(model);
         }
         else
         {
             _category.Insert(model);
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#3
0
        public bool CreateOrUpdate(Article model)
        {
            var result = false;

            try
            {
                if (!string.IsNullOrWhiteSpace(model.ArticleId))
                {
                    _article.Update(model);
                }
                else
                {
                    _article.Insert(model);
                }
                result = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
示例#4
0
 public bool CreateOrUpdate(Category model)
 {
     return(!string.IsNullOrWhiteSpace(model.CategoryId)
         ? _category.Update(model) > 0
         : _category.Insert(model) > 0);
 }