unable to inset data to repositry

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
hi
i am trying to build a plugin with data accesses to nop3.2

now it seems that i cant preform the inset and i cannot find why.

i tried try catch but didnt goy any err .
plz assist...


record map :


  public partial class EtsyOauthRecordMap : EntityTypeConfiguration<EtsyOauthRecord>
    {
        public  EtsyOauthRecordMap()
        {
            ToTable("EtsyOauth");
            HasKey(x => x.Id);

        /*    Property(x => x.StoreName);
            Property(x=>x.oauth_token);
             Property(x=>x.shared_secret);
             Property(x=>x.permanent_token);
             Property(x => x.permanent_secret); */

            
        }
    }
  


record :
 

  public partial class EtsyOauthRecord : BaseEntity
    {
    /*  public int EtsyOauthId { get; set; }*/
        public string StoreName { get; set; }
        public string oauth_token { get; set; }
        public string shared_secret { get; set; }
        public string permanent_token { get; set; }
        public string permanent_secret { get; set; }

    }



controller :

   public ActionResult Auth()

        {
            string oauth_token;
            string oauth_token_secret;
            var model = new EtsyModel();
            var portal = new Etsy_portal("xxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxx");
          
            model.ConfirmUrl = portal.GetConfirmUrl(out oauth_token, out oauth_token_secret, null);
            
           var outhRecord = new EtsyOauthRecord();
      
            outhRecord.StoreName = "mitpachat.com";
            outhRecord.oauth_token = oauth_token;
            outhRecord.shared_secret = oauth_token_secret;

            _EtsyOauthService.InsertEtsyOauthRecord(outhRecord);
          
    
                

            
            return View("Main" ,model);
        }



service :

       public virtual void InsertEtsyOauthRecord(EtsyOauthRecord EtsyOauthRecord)
        {
            if (EtsyOauthRecord == null)
                throw new ArgumentNullException("EtsyOauthRecord");

            _gpRepository.Insert(EtsyOauthRecord);
        }
8 years ago
Did you create your own dbContext?   See the docs about plugin with data access
8 years ago
i have it:

public class EtsyOauthObjectContext : DbContext, IDbContext
    {
        public EtsyOauthObjectContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
            //((IObjectContextAdapter) this).ObjectContext.ContextOptions.LazyLoadingEnabled = true;
        }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new EtsyOauthRecordMap());

            //disable EdmMetadata generation
            //modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
         base.OnModelCreating(modelBuilder);
        }

        public string CreateDatabaseScript()
        {
            return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
        }

        public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
        {
            return base.Set<TEntity>();
        }

        /// <summary>
        /// Install
        /// </summary>
        public void Install()
        {
           // Database.SetInitializer<EtsyOauthObjectContext>(null);

            //create the table
            var dbScript = CreateDatabaseScript();
            Database.ExecuteSqlCommand(dbScript);
            SaveChanges();
        }

        /// <summary>
        /// Uninstall
        /// </summary>
        public void Uninstall()
        {
            //drop the table
            this.DropPluginTable("EtsyOauth");
        }


        public IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Creates a raw SQL query that will return elements of the given generic type.  The type can be any type that has properties that match the names of the columns returned from the query, or can be a simple primitive type. The type does not have to be an entity type. The results of this query are never tracked by the context even if the type of object returned is an entity type.
        /// </summary>
        /// <typeparam name="TElement">The type of object returned by the query.</typeparam>
        /// <param name="sql">The SQL query string.</param>
        /// <param name="parameters">The parameters to apply to the SQL query string.</param>
        /// <returns>Result</returns>
        public IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Executes the given DDL/DML command against the database.
        /// </summary>
        /// <param name="sql">The command string</param>
        /// <param name="doNotEnsureTransaction">false - the transaction creation is not ensured; true - the transaction creation is ensured.</param>
        /// <param name="timeout">Timeout value, in seconds. A null value indicates that the default value of the underlying provider will be used</param>
        /// <param name="parameters">The parameters to apply to the command string.</param>
        /// <returns>The result returned by the database after executing the command.</returns>
        public int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = null, params object[] parameters)
        {
            throw new NotImplementedException();
        }
    }
8 years ago
the only thing that i was able to do is that
in depandecy register i was not able to do the

 this.RegisterPluginDataContext<TrackingRecordObjectContext>(builder, CONTEXT_NAME );



it seems like "RegisterPluginDataContext" does not exits at all at V3.2
also after adding the
using Nop.Web.Framework.Mvc;
8 years ago
i am such an idiot!!
i was calling the insert from the wrong class!!!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.