Exemple #1
0
 public SqlUpdateBuild Update(Goods_tagInfo item)
 {
     return(new SqlUpdateBuild(new List <Goods_tagInfo> {
         item
     }, false)
            .SetGoods_id(item.Goods_id)
            .SetTag_id(item.Tag_id));
 }
Exemple #2
0
 public static Goods_tagInfo Insert(Goods_tagInfo item)
 {
     item = dal.Insert(item);
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(item);
 }
Exemple #3
0
        async public Task <Goods_tagInfo> DeleteAsync(int?Goods_id, int?Tag_id)
        {
            Goods_tagInfo item = null;
            await SqlHelper.ExecuteReaderAsync(async dr => { item = await BLL.Goods_tag.dal.GetItemAsync(dr); }, string.Concat(TSQL.Delete, @"[goods_id] = @goods_id AND [tag_id] = @tag_id"),
                                               new SqlParameter { ParameterName = "@goods_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Goods_id },
                                               new SqlParameter { ParameterName = "@tag_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Tag_id });

            return(item);
        }
Exemple #4
0
        async public static Task <Goods_tagInfo> InsertAsync(Goods_tagInfo item)
        {
            item = await dal.InsertAsync(item);

            if (itemCacheTimeout > 0)
            {
                await RemoveCacheAsync(item);
            }
            return(item);
        }
Exemple #5
0
        async public Task <APIReturn> _Add([FromForm] int?Goods_id, [FromForm] int?Tag_id)
        {
            Goods_tagInfo item = new Goods_tagInfo();

            item.Goods_id = Goods_id;
            item.Tag_id   = Tag_id;
            item          = await Goods_tag.InsertAsync(item);

            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Exemple #6
0
 protected static SqlParameter[] GetParameters(Goods_tagInfo item)
 {
     return(new SqlParameter[] {
         new SqlParameter {
             ParameterName = "@goods_id", SqlDbType = SqlDbType.Int, Size = 4, Value = item.Goods_id
         },
         new SqlParameter {
             ParameterName = "@tag_id", SqlDbType = SqlDbType.Int, Size = 4, Value = item.Tag_id
         }
     });
 }
Exemple #7
0
        async public Task <ActionResult> Edit([FromQuery] int Goods_id, [FromQuery] int Tag_id)
        {
            Goods_tagInfo item = await Goods_tag.GetItemAsync(Goods_id, Tag_id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Exemple #8
0
        public Goods_tagInfo Insert(Goods_tagInfo item)
        {
            Goods_tagInfo newitem = null;

            SqlHelper.ExecuteReader(dr => { newitem = GetItem(dr); }, TSQL.Insert, GetParameters(item));
            if (newitem == null)
            {
                return(null);
            }
            this.CopyItemAllField(item, newitem);
            return(item);
        }
Exemple #9
0
        async public Task <Goods_tagInfo> InsertAsync(Goods_tagInfo item)
        {
            Goods_tagInfo newitem = null;
            await SqlHelper.ExecuteReaderAsync(async dr => { newitem = await GetItemAsync(dr); }, TSQL.Insert, GetParameters(item));

            if (newitem == null)
            {
                return(null);
            }
            this.CopyItemAllField(item, newitem);
            return(item);
        }
Exemple #10
0
        public Goods_tagInfo Delete(int?Goods_id, int?Tag_id)
        {
            Goods_tagInfo item = null;

            SqlHelper.ExecuteReader(dr => { item = BLL.Goods_tag.dal.GetItem(dr); }, string.Concat(TSQL.Delete, @"[goods_id] = @goods_id AND [tag_id] = @tag_id"),
                                    new SqlParameter {
                ParameterName = "@goods_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Goods_id
            },
                                    new SqlParameter {
                ParameterName = "@tag_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Tag_id
            });
            return(item);
        }
Exemple #11
0
        async public Task <APIReturn> _Edit([FromQuery] int Goods_id, [FromQuery] int Tag_id)
        {
            Goods_tagInfo item = await Goods_tag.GetItemAsync(Goods_id, Tag_id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            int affrows = await Goods_tag.UpdateAsync(item);

            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
Exemple #12
0
        public SqlUpdateBuild Update(Goods_tagInfo item, string[] ignoreFields)
        {
            var sub = new SqlUpdateBuild(new List <Goods_tagInfo> {
                item
            }, false);
            var ignore = ignoreFields?.ToDictionary(a => a, StringComparer.CurrentCultureIgnoreCase) ?? new Dictionary <string, string>();

            if (ignore.ContainsKey("goods_id") == false)
            {
                sub.SetGoods_id(item.Goods_id);
            }
            if (ignore.ContainsKey("tag_id") == false)
            {
                sub.SetTag_id(item.Tag_id);
            }
            return(sub);
        }
Exemple #13
0
        public object GetItem(SqlDataReader dr, ref int dataIndex)
        {
            Goods_tagInfo item = new Goods_tagInfo();

            if (!dr.IsDBNull(++dataIndex))
            {
                item.Goods_id = dr.GetInt32(dataIndex);
            }
            if (item.Goods_id == null)
            {
                dataIndex += 1; return(null);
            }
            if (!dr.IsDBNull(++dataIndex))
            {
                item.Tag_id = dr.GetInt32(dataIndex);
            }
            if (item.Tag_id == null)
            {
                dataIndex += 0; return(null);
            }
            return(item);
        }
Exemple #14
0
        async public Task <(object result, int dataIndex)> GetItemAsync(SqlDataReader dr, int dataIndex)
        {
            Goods_tagInfo item = new Goods_tagInfo();

            if (!await dr.IsDBNullAsync(++dataIndex))
            {
                item.Goods_id = await dr.GetFieldValueAsync <int>(dataIndex);
            }
            if (item.Goods_id == null)
            {
                dataIndex += 1; return(null, dataIndex);
            }
            if (!await dr.IsDBNullAsync(++dataIndex))
            {
                item.Tag_id = await dr.GetFieldValueAsync <int>(dataIndex);
            }
            if (item.Tag_id == null)
            {
                dataIndex += 0; return(null, dataIndex);
            }
            return(item, dataIndex);
        }
 public static string ToJson(this Goods_tagInfo item) => string.Concat(item);
Exemple #16
0
 private void CopyItemAllField(Goods_tagInfo item, Goods_tagInfo newitem)
 {
     item.Goods_id = newitem.Goods_id;
     item.Tag_id   = newitem.Tag_id;
 }
Exemple #17
0
 public static int Update(Goods_tagInfo item, _ ignore1 = 0, _ ignore2 = 0, _ ignore3 = 0) => Update(item, new[] { ignore1, ignore2, ignore3 });
Exemple #18
0
 public static int Update(Goods_tagInfo item, _[] ignore) => dal.Update(item, ignore?.Where(a => a > 0).Select(a => Enum.GetName(typeof(_), a)).ToArray()).ExecuteNonQuery();
Exemple #19
0
 async public static Task <int> UpdateAsync(Goods_tagInfo item) => await dal.Update(item).ExecuteNonQueryAsync();
Exemple #20
0
 async internal static Task RemoveCacheAsync(Goods_tagInfo item) => await RemoveCacheAsync(item == null?null : new [] { item });
Exemple #21
0
 public static int Update(Goods_tagInfo item) => dal.Update(item).ExecuteNonQuery();
Exemple #22
0
 internal static void RemoveCache(Goods_tagInfo item) => RemoveCache(item == null ? null : new [] { item });
Exemple #23
0
 public static Task <int> UpdateAsync(Goods_tagInfo item, _ ignore1 = 0, _ ignore2 = 0, _ ignore3 = 0) => UpdateAsync(item, new[] { ignore1, ignore2, ignore3 });