Пример #1
0
 public TagService(MysqlContext mysqlContext, IMemoryCache memoryCache)
 {
     _mysqlContext              = mysqlContext;
     _tagEfRepository           = new EfRepository <Tag>(this._mysqlContext);
     _blogTagMapperEfRepository = new EfRepository <BlogTagMapper>(this._mysqlContext);
     _memoryCache = memoryCache;
 }
Пример #2
0
 public LoginHandle(MysqlContext context, HttpContext httpContext, ICustomerService customerService)
 {
     this._context            = context;
     this._httpContext        = httpContext;
     this._customerRepository = new EfRepository <Customer>(this._context);
     this._customerService    = customerService;
 }
Пример #3
0
 public PictureController(MysqlContext context, IHostingEnvironment env, IOptions <LocalDir> option)
 {
     _context = context;
     _env     = env;
     this._customerRepository = new EfRepository <Customer>(this._context);
     this._pictureRepository  = new EfRepository <Picture>(this._context);
     _localDir = option.Value;
 }
Пример #4
0
 public BlogListViewComponent(MysqlContext context, IBlogService blogService, ICustomerService customerService)
 {
     this._context            = context;
     this._blogService        = blogService;
     this._customerService    = customerService;
     this._customerRepository = new EfRepository <Customer>(this._context);
     this._blogRepository     = new EfRepository <Blog>(this._context);
 }
Пример #5
0
        static void Main(string[] args)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();
            var before2 = GC.CollectionCount(2);
            var before1 = GC.CollectionCount(1);
            var before0 = GC.CollectionCount(0);

            var dataBase = new MysqlContext();
            var repo = new Repository<Supplier>(dataBase);

            //Insert 
            Supplier supplier1 = new Supplier();
            supplier1.Name = "SUPLIER 1";
            supplier1.Products = new List<Product>
            {
                new Product { Name = "PRODUCT TEST 1 ", Price = 10, Quantity = 1 },
                new Product { Name = "PRODUCT TEST 2 ", Price = 5, Quantity = 4 }
            };

            repo.Add(supplier1);

            repo.SaveChanges();

            Supplier supplier2 = new Supplier();
            supplier2.Name = "SUPLIER 2";
            supplier2.Products = new List<Product>
            {
                new Product { Name = "PRODUCT TEST 3", Price = 10, Quantity = 1 },
                new Product { Name = "PRODUCT TEST 4 ", Price = 5, Quantity = 4 }
            };

            repo.Add(supplier2);

            repo.SaveChanges();
            //End Insert 

            var SupplierGetAll = repo.GetAll();
            var SupplierGetId = repo.GetbyId(2);
            var SupplierGet = repo.Get(s => s.Name == "SUPLIER 1");

            watch.Stop();
            TimeSpan ts = watch.Elapsed;

            System.Console.WriteLine($"Tempo total: {watch.ElapsedMilliseconds}ms");
            System.Console.WriteLine($"GC Gen #2  : {GC.CollectionCount(2) - before2}");
            System.Console.WriteLine($"GC Gen #1  : {GC.CollectionCount(1) - before1}");
            System.Console.WriteLine($"GC Gen #0  : {GC.CollectionCount(0) - before0}");
            System.Console.WriteLine("Done!");

            System.Console.WriteLine("Tempo: " + ts.ToString("mm\\:ss\\.ff"));
            System.Console.WriteLine();


            System.Console.ReadKey();


        }
        /// <summary>
        /// Removes a given contact from the repo.
        /// </summary>
        /// <param name="contact">Contact to remove.</param>
        public void Remove(InvoiceItem invoiceItem)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(invoiceItem).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Adds a new contact to the repo.
        /// </summary>
        /// <param name="contact">Contact to add.</param>
        public void Add(Contact contact)
        {
            using (var context = new MysqlContext())
            {
                context.Contacts.Add(contact);

                context.SaveChanges();
            }
        }
Пример #8
0
        public HomeController(MysqlContext context, INormalCommentService normalCommentService)
        {
            //var options = new DbContextOptions<MysqlContext>();

            //this._context = new MysqlContext(options);
            this._context              = context;
            this._customerRepository   = new EfRepository <Customer>(this._context);
            this._normalCommentService = normalCommentService;
        }
        /// <summary>
        /// Tries to store (persist) data about a given accountingCode.
        /// </summary>
        /// <param name="accountingCode">AccountingCode to be persisted in the repo.</param>
        public void Store(AccountingCode accountingCode)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(accountingCode).State = ((accountingCode.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Removes a given receipt from the repo.
        /// </summary>
        /// <param name="receipt">Receipt to remove.</param>
        public void Remove(Receipt receipt)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(receipt).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
Пример #11
0
        /// <summary>
        /// Tries to store (persist) data about a given user.
        /// </summary>
        /// <param name="user">User to be persisted in the repo.</param>
        public void Store(User user)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(user).State = ((user.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
Пример #12
0
 public BlogService(MysqlContext mysqlContext, IMemoryCache memoryCache, ITagService tagService, IOptions <PageSettings> option)
 {
     _mysqlContext            = mysqlContext;
     _blogRepository          = new EfRepository <Blog>(this._mysqlContext);
     _blogTagMapperRepository = new EfRepository <BlogTagMapper>(this._mysqlContext);
     _memoryCache             = memoryCache;
     _tagService   = tagService;
     _pageSettings = option.Value;
 }
        /// <summary>
        /// Tries to store (persist) data about a given journal.
        /// </summary>
        /// <param name="journal">Journal to be persisted in the repo.</param>
        public void Store(Journal journal)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(journal).State = ((journal.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Removes a given journal from the repo.
        /// </summary>
        /// <param name="journal">Journal to remove.</param>
        public void Remove(Journal journal)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(journal).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Adds a new journal to the repo.
        /// </summary>
        /// <param name="journal">Journal to add.</param>
        public void Add(Journal journal)
        {
            using (var context = new MysqlContext())
            {
                context.Journals.Add(journal);

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Tries to store (persist) data about a given contact.
        /// </summary>
        /// <param name="contact">Contact to be persisted in the repo.</param>
        public void Store(InvoiceItem invoiceItem)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(invoiceItem).State = ((invoiceItem.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
Пример #17
0
        /// <summary>
        /// Adds a new user to the repo.
        /// </summary>
        /// <param name="user">User to add.</param>
        public void Add(User user)
        {
            using (var context = new MysqlContext())
            {
                context.Users.Add(user);

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Adds a new accountingCode to the repo.
        /// </summary>
        /// <param name="accountingCode">AccountingCode to add.</param>
        public void Add(AccountingCode accountingCode)
        {
            using (var context = new MysqlContext())
            {
                context.AccountingCodes.Add(accountingCode);

                context.SaveChanges();
            }
        }
Пример #19
0
        /// <summary>
        /// Removes a given user from the repo.
        /// </summary>
        /// <param name="user">User to remove.</param>
        public void Remove(User user)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(user).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Removes a given accountingCode from the repo.
        /// </summary>
        /// <param name="accountingCode">AccountingCode to remove.</param>
        public void Remove(AccountingCode accountingCode)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(accountingCode).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Adds a new receipt to the repo.
        /// </summary>
        /// <param name="receipt">Receipt to add.</param>
        public void Add(Receipt receipt)
        {
            using (var context = new MysqlContext())
            {
                context.Receipts.Add(receipt);

                context.SaveChanges();
            }
        }
Пример #22
0
 public BuyerService(MysqlContext mysqlContext, IMemoryCache memoryCache)
 {
     this._mysqlContext = mysqlContext;
     _buyerRepository   = new EfRepository <LotteryBuyer>(this._mysqlContext);
     _pool0Repository   = new EfRepository <LotteryPool0>(this._mysqlContext);
     _pool1Repository   = new EfRepository <LotteryPool1>(this._mysqlContext);
     _issueRepository   = new EfRepository <LotteryIssue>(this._mysqlContext);
     _memoryCache       = memoryCache;
 }
        /// <summary>
        /// Adds a new contact to the repo.
        /// </summary>
        /// <param name="contact">Contact to add.</param>
        public void Add(InvoiceItem invoiceItem)
        {
            using (var context = new MysqlContext())
            {
                context.InvoiceItems.Add(invoiceItem);

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Tries to store (persist) data about a given statement.
        /// </summary>
        /// <param name="statement">Statement to be persisted in the repo.</param>
        public void Store(Statement statement)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(statement).State = ((statement.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Removes a given statement from the repo.
        /// </summary>
        /// <param name="statement">Statement to remove.</param>
        public void Remove(Statement statement)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(statement).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Adds a new statement to the repo.
        /// </summary>
        /// <param name="statement">Statement to add.</param>
        public void Add(Statement statement)
        {
            using (var context = new MysqlContext())
            {
                context.Statements.Add(statement);

                context.SaveChanges();
            }
        }
Пример #27
0
 public CustomerExpectationService(MysqlContext mysqlContext)
 {
     this._mysqlContext = mysqlContext;
     this._customerExpectationRepository  = new EfRepository <CustomerExpectation>(this._mysqlContext);
     this._cCreditCardCarLoanRepository   = new EfRepository <CCreditCardCarLoan>(this._mysqlContext);
     this._cLifeInsuranceRepository       = new EfRepository <CLifeInsurance>(this._mysqlContext);
     this._cRealEstateRepository          = new EfRepository <CRealEstate>(this._mysqlContext);
     this._customerHiredRepository        = new EfRepository <CustomerHired>(this._mysqlContext);
     this._customerSelfEmployedRepository = new EfRepository <CustomerSelfEmployed>(this._mysqlContext);
 }
Пример #28
0
 public CustomerService(MysqlContext mysqlContext, IMemoryCache memoryCache)
 {
     this._memoryCache                  = memoryCache;
     this._mysqlContext                 = mysqlContext;
     _customerRepository                = new EfRepository <Customer>(this._mysqlContext);
     _authorizationRepository           = new EfRepository <Authorization>(this._mysqlContext);
     _customerRoleMapperRepository      = new EfRepository <CustomerRoleMapper>(this._mysqlContext);
     _roleAuthorizationMapperRepository = new EfRepository <RoleAuthorizationMapper>(this._mysqlContext);
     _roleRepository = new EfRepository <Role>(this._mysqlContext);
 }
 /// <summary>
 /// Tries to load data about a given statement (according to their ID) and returns the information loaded.
 /// </summary>
 /// <param name="statement">Information identifying the statement to be loaded (their ID).</param>
 /// <returns>Returns the requested statement. If no such statement exists, the method should throw an exception.</returns>
 public Statement Load(Statement statement)
 {
     if (!Exists(statement))
     {
         throw new Exception($"There's no such statement with ID: {statement.ID}");
     }
     using (var context = new MysqlContext())
     {
         return(context.Statements.Find(statement.ID));
     }
 }
 /// <summary>
 /// Tries to load data about a given receipt (according to their ID) and returns the information loaded.
 /// </summary>
 /// <param name="receipt">Information identifying the receipt to be loaded (their ID).</param>
 /// <returns>Returns the requested receipt. If no such receipt exists, the method should throw an exception.</returns>
 public Receipt Load(Receipt receipt)
 {
     if (!Exists(receipt))
     {
         throw new Exception($"There's no such receipt with ID: {receipt.ID}");
     }
     using (var context = new MysqlContext())
     {
         return(context.Receipts.Find(receipt.ID));
     }
 }