Beispiel #1
0
        private void SaveUsing(IDbConnection conn, IDbTransaction t, bool noLinkUpdates)
        {
            long?collectionId = null;

            if (Id == null)
            {
                var parameters = new List <Tuple <string, DbType, object> >();
                var paramCode  = new Tuple <string, DbType, object>("@Code", DbType.String, Code);
                var paramName  = new Tuple <string, DbType, object>("@Description", DbType.String, Description);
                parameters.Add(paramCode);
                parameters.Add(paramName);
                string sql = "INSERT INTO sku_collections (Code, Description) VALUES (@Code, @Description);";
                collectionId = DBHandler.Insert(sql, parameters, conn, t);
            }
            else
            {
                collectionId = Id;
                conn.Update(this, t);
            }
            if (!noLinkUpdates)
            {
                SKUCollectionLink.Delete(conn, t, (long)collectionId, null);
                SKUs.ForEach(sku => SKUCollectionLink.Create(conn, t, (long)collectionId, (long)sku.Id));
            }
        }
Beispiel #2
0
 public void Delete(IDbConnection conn = null, IDbTransaction t = null)
 {
     if (conn == null)
     {
         using (var c = DBHandler.Connection())
         {
             c.Open();
             using (var tr = c.BeginTransaction())
             {
                 c.Delete(this, tr);
                 SKUCollectionLink.Delete(c, tr, null, Id);
                 tr.Commit();
             }
         }
     }
     else
     {
         conn.Delete(this, t);
         SKUCollectionLink.Delete(conn, t, null, Id);
     }
 }
Beispiel #3
0
 private void DeleteUsing(IDbConnection conn, IDbTransaction t)
 {
     conn.Delete(this, t);
     SKUCollectionLink.Delete(conn, t, Id, null);
 }