コード例 #1
0
 private int InsertUpdate(Tag entity, int? userId, DbActionType action, bool intoCache)
 {
     var cache = new CacheWrapper();
     var res = TagsDataAdapter.InsertUpdate(entity, userId, action);
     if (res == 0)
     {
         //if ok - update cache
         if (intoCache)
         {
             if (action == DbActionType.Insert)
                 cache.AddToList(CacheKey, entity, userId);
             if (action == DbActionType.Update)
                 cache.UpdateList(CacheKey, entity, userId);
         }
     }
     return res;
 }
コード例 #2
0
 public static int InsertUpdate(Tag entity, int? userId, DbActionType action)
 {
     var res = -1;
     using (var holder = SqlConnectionHelper.GetConnection())
     {
         var commName = action == DbActionType.Insert ? "tag_create" : "web.tag_update";
         var cmd = holder.Connection.CreateSPCommand(commName);
         try
         {
             cmd.AddEntityParameters(entity, action);
             cmd.ExecuteNonQuery();
             if (action == DbActionType.Insert)
                 entity.Id = cmd.GetRowIdParameter();
             res = cmd.GetReturnParameter();
         }
         catch (SqlException e)
         {
             cmd.AddDetailsToException(e);
             throw;
         }
     }
     return res;
 }
コード例 #3
0
ファイル: Tag.cs プロジェクト: Naviam/Home-Accounting-Old
 /// <summary>
 /// Appends Tag-specific parameters to the specificied SqlCommand. 
 /// </summary>
 /// <param name="command">SqlCommand to be executed.</param>
 /// <param name="alert">Instance of Tag class</param>
 /// <param name="action">Database action type (select, insert, update, delete).</param>
 public static void AddEntityParameters(this SqlCommand command, Tag entity, DbActionType action)
 {
     command.AddCommonParameters(entity.Id, action);
     command.Parameters.Add("@name", SqlDbType.NVarChar).Value = entity.Name.ToDbValue();
     command.Parameters.Add("@id_user", SqlDbType.Int).Value = entity.UserId.ToDbValue();
 }
コード例 #4
0
 public virtual int Update(Tag entity, int? userId)
 {
     return InsertUpdate(entity, userId, DbActionType.Update, true);
 }
コード例 #5
0
 public virtual int Insert(Tag entity, int? userId, bool intoCache)
 {
     return InsertUpdate(entity, userId, DbActionType.Insert, intoCache);
 }
コード例 #6
0
 public virtual int Insert(Tag entity, int? userId)
 {
     return Insert(entity, userId, true);
 }