Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        public void VoidInsertListTimeControl(List <TModel> entities, DateTime requestTime)
        {
            using (var context = new DBContext.DBContext())
            {
                using (DbContextTransaction transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        DALHelperMethods.HelperDALMethods.CheckRequestTimeOutDAL(requestTime);


                        //  dbSet.AddRange(entities);
                        foreach (var entity in entities)
                        {
                            DALHelperMethods.HelperDALMethods.CheckRequestTimeOutDAL(requestTime);

                            Customer newCustomer = new Customer();

                            foreach (PropertyInfo pi in entity.GetType().GetProperties())
                            {
                                try
                                {
                                    //get the value of property and try
                                    //to assign it to the property of T type object:
                                    newCustomer.GetType().GetProperty(pi.Name).SetValue(newCustomer,
                                                                                        pi.GetValue(entity, null), null);
                                }
                                catch (Exception ex)
                                {
                                    throw;
                                }
                            }

                            DALHelperMethods.HelperDALMethods.CheckRequestTimeOutDAL(requestTime);

                            context.Customers.Add(newCustomer);

                            context.SaveChanges();
                        }

                        DALHelperMethods.HelperDALMethods.CheckRequestTimeOutDAL(requestTime);


                        transaction.Commit();
                    }

                    catch (Exception e)
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #2
0
 public RateRepository(DBContext.DBContext _context) : base(_context)
 {
 }
Example #3
0
 public RepositoryBase(DBContext.DBContext _context)
 {
     context = _context;
 }
Example #4
0
 public BankRepository(DBContext.DBContext _context) : base(_context)
 {
 }
Example #5
0
 public TalentRepository(DBContext.DBContext _context) : base(_context)
 {
 }