/// <summary> /// 带事务的Update /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2015/10/19 15:46:38</remarks> public bool Update(ConfigFriendinviteprizeEntity entity, DbTransaction trans) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_ConfigFriendinviteprize_Update"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx); database.AddInParameter(commandWrapper, "@SucceedCount", DbType.Int32, entity.SucceedCount); database.AddInParameter(commandWrapper, "@PrizeType", DbType.Int32, entity.PrizeType); database.AddInParameter(commandWrapper, "@ItemCode", DbType.Int32, entity.ItemCode); database.AddInParameter(commandWrapper, "@Count", DbType.Int32, entity.Count); database.AddInParameter(commandWrapper, "@IsBinding", DbType.Boolean, entity.IsBinding); int results = 0; if (trans != null) { results = database.ExecuteNonQuery(commandWrapper, trans); } else { results = database.ExecuteNonQuery(commandWrapper); } return(Convert.ToBoolean(results)); }
/// <summary> /// 将IDataReader的当前记录读取到ConfigFriendinviteprizeEntity 对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> public ConfigFriendinviteprizeEntity LoadSingleRow(IDataReader reader) { var obj = new ConfigFriendinviteprizeEntity(); obj.Idx = (System.Int32)reader["Idx"]; obj.SucceedCount = (System.Int32)reader["SucceedCount"]; obj.PrizeType = (System.Int32)reader["PrizeType"]; obj.ItemCode = (System.Int32)reader["ItemCode"]; obj.Count = (System.Int32)reader["Count"]; obj.IsBinding = (System.Boolean)reader["IsBinding"]; return(obj); }
/// <summary> /// GetById /// </summary> /// <param name="idx">idx</param> /// <returns>ConfigFriendinviteprizeEntity</returns> /// <remarks>2015/10/19 15:46:38</remarks> public ConfigFriendinviteprizeEntity GetById(System.Int32 idx) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("P_ConfigFriendinviteprize_GetById"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx); ConfigFriendinviteprizeEntity obj = null; using (IDataReader reader = database.ExecuteReader(commandWrapper)) { if (reader.Read()) { obj = LoadSingleRow(reader); } } return(obj); }
public PriendInvitePrizeList FriendInvitePrizeList(string account, Guid managerId) { PriendInvitePrizeList response = new PriendInvitePrizeList(); response.ItemList = new List <ItemInfo>(); //获取成功邀请人数 var count = NbManagerextraMgr.GetInviteFriendCount(managerId); response.InviteCount = count; var result = CacheFactory.FriendCache.GetAllPrize(); ConfigFriendinviteprizeEntity[] dic = new ConfigFriendinviteprizeEntity[result.Count]; result.CopyTo(dic); if (dic != null && dic.Length != 0) { response.IsInviteAccomplish = false; //获取领取奖励记录 var record = FriendinvitePrizerecordMgr.InvitePrizeIsGet(account); List <ConfigFriendinviteprizeEntity> list = new List <ConfigFriendinviteprizeEntity>(); //移除领取过的奖励 foreach (var item in record) { if (ConvertHelper.ConvertToInt(item.PrizeInfo) == 0) { continue; } foreach (var item1 in dic) { if (item1.SucceedCount == ConvertHelper.ConvertToInt(item.PrizeInfo)) { continue; } list.Add(item1); } if (list.Count != 0) { dic = list.ToArray(); list = new List <ConfigFriendinviteprizeEntity>(); } } //留下最低挡的奖励 int idx = dic.Min(r => r.SucceedCount); foreach (var item in dic) { if (item.SucceedCount == idx) { list.Add(item); } } response.NextInviteCount = list[0].SucceedCount - count < 0 ? 0 : list[0].SucceedCount - count; response.PrizeId = list[0].SucceedCount; foreach (var item in list) { ItemInfo info = new ItemInfo(); info.Count = item.Count; info.ItemCode = item.ItemCode; info.PrizeType = item.PrizeType; info.IsBinding = item.IsBinding; response.ItemList.Add(info); } } else { response.IsInviteAccomplish = true; } return(response); }
public static bool Update(ConfigFriendinviteprizeEntity configFriendinviteprizeEntity, DbTransaction trans = null, string zoneId = "") { var provider = new ConfigFriendinviteprizeProvider(zoneId); return(provider.Update(configFriendinviteprizeEntity, trans)); }
/// <summary> /// Update /// </summary> /// <param name="entity"></param> /// <returns></returns> /// <remarks>2015/10/19 15:46:38</remarks> public bool Update(ConfigFriendinviteprizeEntity entity) { return(Update(entity, null)); }
/// <summary> /// Insert /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2015/10/19 15:46:38</remarks> public bool Insert(ConfigFriendinviteprizeEntity entity) { return(Insert(entity, null)); }