public bool Update(ShareArticleEntity model)
        {
            var description = "更新分享文章";

            try
            {
                var sql          = @"update [dbo].[ShareArticle]
 set 
 [Title]=@Title,
 [ArticleUrl]=@ArticleUrl,
 [ArticleType]=@ArticleType,
 [CreatedTime]=@CreatedTime,
 [UpdatedTime]=@UpdatedTime,
 [Cover]=@Cover
 Where Id=@Id
";
                var sqlParameter = new List <SqlParameter> {
                    new SqlParameter("@Id", SqlDbType.BigInt)
                    {
                        Value = model.Id
                    },
                    new SqlParameter("@Title", SqlDbType.NVarChar)
                    {
                        Value = model.Title
                    },
                    new SqlParameter("@ArticleUrl", SqlDbType.NVarChar)
                    {
                        Value = model.ArticleUrl
                    },
                    new SqlParameter("@ArticleType", SqlDbType.Int)
                    {
                        Value = model.ArticleType
                    },
                    new SqlParameter("@CreatedTime", SqlDbType.DateTime)
                    {
                        Value = model.CreatedTime
                    },
                    new SqlParameter("@UpdatedTime", SqlDbType.DateTime)
                    {
                        Value = model.UpdatedTime
                    },
                    new SqlParameter("@Cover", SqlDbType.NVarChar)
                    {
                        Value = model.Cover
                    },
                };
                RPoney.Log.LoggerManager.Debug(GetType().Name, $"{description}sql:{sql},参数:model{model.SerializeToJSON()}");
                return(DataBaseManager.MainDb().ExecuteNonQuery(sql, sqlParameter.ToArray()) > 0);
            }
            catch (Exception ex)
            {
                RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex);
                return(false);
            }
        }
Пример #2
0
 public bool Save(ShareArticleEntity entity)
 {
     if (entity.Id > 0)
     {
         return(Update(entity));
     }
     else
     {
         return(Add(entity) > 0);
     }
 }
        public long Add(ShareArticleEntity model)
        {
            var description = "添加分享文章";

            try
            {
                var sql          = @"INSERT INTO [dbo].[ShareArticle]([Title],[ArticleUrl],[ArticleType],[CreatedTime],[UpdatedTime],[Cover])
Values(@Title,@ArticleUrl,@ArticleType,@CreatedTime,@UpdatedTime,@Cover);select @@Identity;";
                var sqlParameter = new List <SqlParameter> {
                    new SqlParameter("@Title", SqlDbType.NVarChar)
                    {
                        Value = model.Title
                    },
                    new SqlParameter("@ArticleUrl", SqlDbType.NVarChar)
                    {
                        Value = model.ArticleUrl
                    },
                    new SqlParameter("@ArticleType", SqlDbType.Int)
                    {
                        Value = model.ArticleType
                    },
                    new SqlParameter("@CreatedTime", SqlDbType.DateTime)
                    {
                        Value = model.CreatedTime
                    },
                    new SqlParameter("@UpdatedTime", SqlDbType.DateTime)
                    {
                        Value = model.UpdatedTime
                    },
                    new SqlParameter("@Cover", SqlDbType.NVarChar)
                    {
                        Value = model.Cover
                    },
                };
                RPoney.Log.LoggerManager.Debug(GetType().Name, $"{description}sql:{sql},参数:model{model.SerializeToJSON()}");
                return(DataBaseManager.MainDb().ExecuteScalar(sql, sqlParameter.ToArray()).CLong(0, false));
            }
            catch (Exception ex)
            {
                RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex);
                return(-1);
            }
        }
        public ActionResult Save(ShareArticleEntity model)
        {
            var entity = _shareArticleBll.Value.Get(model.Id) ?? new ShareArticleEntity();

            entity.Title       = model.Title;
            entity.ArticleUrl  = model.ArticleUrl;
            entity.ArticleType = model.ArticleType;
            entity.Cover       = model.Cover;
            if (entity.Id == 0)
            {
                entity.CreatedTime = DateTime.Now;
            }
            entity.UpdatedTime = DateTime.Now;
            var description = "保存分享文章";

            if (_shareArticleBll.Value.Save(entity))
            {
                return(LayerHelper.SuccessAndClose("", $"{description}成功"));
            }
            return(LayerHelper.Warn($"{description}失败"));
        }
Пример #5
0
        public ActionResult Add()
        {
            var msg = string.Empty;

            for (var i = 0; i < 10; i++)
            {
                var entity = new ShareArticleEntity()
                {
                    Title       = "手把手教你运营" + i,
                    ArticleType = PublicEnum.ShareArticleTypeEnum.YunYinGanHuo,
                    ArticleUrl  = "http://www.cnblogs.com/xrainchen/category/893050.html",
                    CreatedTime = DateTime.Now,
                    UpdatedTime = DateTime.Now
                };
                if (i % 2 == 0)
                {
                    entity.ArticleType = PublicEnum.ShareArticleTypeEnum.TuiGuangFangFaChuangShou;
                }
                msg += _shareArticleBll.Value.Add(entity) + ",";
            }
            return(Content(msg));
        }
Пример #6
0
 public bool Update(ShareArticleEntity entity)
 {
     return(_shareArticleDal.Value.Update(entity));
 }
Пример #7
0
 public long Add(ShareArticleEntity model)
 {
     return(_shareArticleDal.Value.Add(model));
 }
 public ActionResult Edit(ShareArticleEntity model)
 {
     return(View(_shareArticleBll.Value.Get(model.Id) ?? new ShareArticleEntity()));
 }