public ActionResult Save(YinLiuTagViewModel model) { var description = ""; var entity = new YinLiuTagEntity(); if (model.Id > 0)//编辑 { description = "保存标签"; entity = _yinLiuTagBll.Value.Get(model.Id); entity.Name = model.Name; } else//添加 { description = "添加标签"; entity.Name = model.Name; entity.Type = PublicEnum.YinLiuTagTypeEnum.System; } var result = _yinLiuTagBll.Value.Save(entity); if (result) { return(LayerHelper.SuccessAndClose("", $"{description}成功")); } return(LayerHelper.Warn($"{description}失败")); }
public bool Save(YinLiuTagEntity entity) { if (entity.Id > 0) { return(Update(entity)); } else { return(Add(entity) > 0); } }
public bool Update(YinLiuTagEntity model) { var description = "更新引流标签"; try { var sql = @"UPDATE [dbo].[YinLiuTag] SET [Name]=@Name,[Type]=Type,[ProductUserId]=@ProductUserId,[Sort]=@Sort,[CreatedTime]=@CreatedTime Where Id=@Id "; var parameter = new List <SqlParameter> { new SqlParameter("@Id", SqlDbType.BigInt) { Value = model.Id }, new SqlParameter("@Name", SqlDbType.NVarChar) { Value = model.Name }, new SqlParameter("@Type", SqlDbType.Int) { Value = (int)model.Type }, new SqlParameter("@ProductUserId", SqlDbType.BigInt) { Value = model.ProductUserId }, new SqlParameter("@Sort", SqlDbType.Int) { Value = model.Sort }, new SqlParameter("@CreatedTime", SqlDbType.DateTime) { Value = model.CreatedTime } }; return(DataBaseManager.MainDb().ExecuteNonQuery(sql, parameter.ToArray()) > 0); } catch (Exception ex) { RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(false); } }
public long Add(YinLiuTagEntity model) { var description = "添加引流标签"; try { var sql = @" INSERT INTO [dbo].[YinLiuTag]([Name],[Type],[ProductUserId],[Sort],[CreatedTime]) VALUES(@Name,@Type,@ProductUserId,@Sort,@CreatedTime); select @@IDENTITY;"; var parameter = new List <SqlParameter> { new SqlParameter("@Name", SqlDbType.NVarChar) { Value = model.Name }, new SqlParameter("@Type", SqlDbType.Int) { Value = (int)model.Type }, new SqlParameter("@ProductUserId", SqlDbType.BigInt) { Value = model.ProductUserId }, new SqlParameter("@Sort", SqlDbType.Int) { Value = model.Sort }, new SqlParameter("@CreatedTime", SqlDbType.DateTime) { Value = DateTime.Now } }; return(DataBaseManager.MainDb().ExecuteScalar(sql, parameter.ToArray()).CLong(0, false)); } catch (Exception ex) { RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(-1); } }
public bool Update(YinLiuTagEntity model) { return(_yinLiuTagDal.Value.Update(model)); }
public long Add(YinLiuTagEntity model) { return(_yinLiuTagDal.Value.Add(model)); }