Esempio n. 1
0
        public void Load <T>(IEnumerable <T> ts, bool save) where T : class
        {
            using (var context = new AccountingContext())
            {
                var dbSet = context
                            .GetType()
                            .GetProperty(this.pluralizationService.Pluralize(typeof(T).Name))
                            .GetValue(context, null) as DbSet <T>;

                if (dbSet == null)
                {
                    throw new Exception("could not cast to DbSet<T> for T = " + typeof(T).Name);
                }

                foreach (var t in ts)
                {
                    dbSet.AddOrUpdate(t);
                }

                if (save)
                {
                    context.SaveChanges();
                }
            }
        }
Esempio n. 2
0
    public AccountingContext accounting()
    {
        AccountingContext _localctx = new AccountingContext(Context, State);

        EnterRule(_localctx, 0, RULE_accounting);
        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 8; operation();
                State = 9; operation();
                State = 10; operation();
                State = 11; operation();
                State = 12; Match(Eof);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
Esempio n. 3
0
        private async Task CreateUserRoles(IServiceProvider serviceProvider, AccountingContext context)
        {
            var roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();
            var userManager = serviceProvider.GetRequiredService <UserManager <User> >();

            // local variables
            DateTime createdDate        = new DateTime(2016, 03, 01, 12, 30, 00);
            DateTime lastModifiedDate   = DateTime.Now;
            string   roleAdministrators = "Administrators";
            string   roleRegistered     = "Registered";

            //Create Roles (if they doesn't exist yet)
            if (!await roleManager.RoleExistsAsync(roleAdministrators))
            {
                await roleManager.CreateAsync(new IdentityRole(roleAdministrators));
            }

            if (!await roleManager.RoleExistsAsync(roleRegistered))
            {
                await roleManager.CreateAsync(new IdentityRole(roleRegistered));
            }

            // Create the "Admin" ApplicationUser account (if it doesn't exist already)
            var userAdmin = new User
            {
                UserName = "******",
                Email    = "*****@*****.**"
            };

            // Insert "Admin" into the Database and also assign the "Administrator"
            // role to him.
            if (await userManager.FindByNameAsync(userAdmin.UserName) == null)
            {
                await userManager.CreateAsync(userAdmin, "12345678x@X");

                await userManager.AddToRoleAsync(userAdmin, roleAdministrators);

                userAdmin.EmailConfirmed = true;
                userAdmin.LockoutEnabled = true;
            }

#if DEBUG
            var userMinh = new User
            {
                UserName = "******",
                Email    = "*****@*****.**"
            };

            if (await userManager.FindByNameAsync(userMinh.UserName) == null)
            {
                await userManager.CreateAsync(userMinh, "12345678x@X");

                await userManager.AddToRoleAsync(userMinh, roleRegistered);

                userMinh.EmailConfirmed = true;
                userMinh.LockoutEnabled = true;
            }
#endif
            await context.SaveChangesAsync();
        }
Esempio n. 4
0
        // This action renders the form
        public ActionResult Index()
        {
            AccountingContext context = new AccountingContext();
            var model = context.UploadedFiles;

            return(View(model));
        }
        public void Service__GetsAllAccounts()
        {
            // Arrange
            var accountList = new[] {
                GetMockAccount(0987890UL, "test1", 123m, 456m, false),
                GetMockAccount(1987098UL, "test2", 789m, 010m, true)
            };

            var options = new DbContextOptionsBuilder <AccountingContext>()
                          .UseInMemoryDatabase(databaseName: "GetsAllAccounts")
                          .Options;

            // Act
            using (var context = new AccountingContext(options))
            {
                _service = new AccountService(context);

                foreach (var account in accountList)
                {
                    _service.Add(account);
                }

                // Assert
                Assert.Equal(_service.GetAccounts(), accountList);
            }
        }
Esempio n. 6
0
 public AcctRepoSqlServer(AccountingContext context, ADContext adContext, IOptionsSnapshot <AppSettings> settings)
 {
     _settings             = settings;
     _remoteServiceBaseUrl = $"{settings.Value.IdentityUrl}/api/task";
     _context   = context;
     _adContext = adContext;
 }
Esempio n. 7
0
        public ActionResult Details(int id)
        {
            AccountingContext context = new AccountingContext();

            var model = context.Fields.Where(x => x.UploadedFileInfoId == id);

            return(View(model));
        }
Esempio n. 8
0
 public UnitOfWork(AccountingContext accountingContext,
                   IAccountRepository accountRepository,
                   ICurrencyRepository currencyRepository)
 {
     this.accountingContext = accountingContext ?? throw new ArgumentNullException("accountingContext");
     this.Accounts          = accountRepository ?? throw new ArgumentNullException("accountRepository");
     this.Currencies        = currencyRepository ?? throw new ArgumentNullException("currencyRepository");
 }
Esempio n. 9
0
        public ActionResult Index(HttpPostedFileBase file, UploadedFileInfo upload)
        {
            //check file extension
            string extension = Path.GetExtension(Request.Files[0].FileName).ToLower();

            if (extension != ".xls" && extension != ".xlsx")
            {
                ModelState.AddModelError("uploadError", "Supported file extensions: .xls, .xlsx");
                return(View());
            }

            // extract only the filename
            var fileName = Path.GetFileName(file.FileName);

            //display adding date
            var currentDate = DateTime.Now.ToString("d");

            // store the file inside ~/App_Data/uploads folder
            var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), currentDate + fileName);

            using (AccountingContext context = new AccountingContext())
            {
                // Verify that the user selects a file
                if (file != null && file.ContentLength > 0)
                {
                    file.SaveAs(path);

                    // save the filename and path in UploadedFilesInfo table
                    upload.FileName = fileName;
                    upload.FilePath = path;

                    context.UploadedFiles.Add(upload);

                    context.SaveChanges();
                }
                else
                {
                    ModelState.AddModelError("blankFileError", "You're trying to attach blank file.");
                    return(View());
                }

                ExcelHandler excelHandler = new ExcelHandler();
                FileInfo     fi1          = new FileInfo(path);

                var queryId = from customer in context.UploadedFiles
                              select customer.UploadedFileInfoId;

                int?currentId = queryId.ToList().Last();

                var id = currentId++ ?? 1;

                excelHandler.SelectDataFromFile(fi1, id);
            }

            // redirect back to the index action to show the form once again
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
        private async Task <List <ProductPrice> > FillProductPrices(int catId, DateTime dateFrom, DateTime dateTo)
        {
            var context = new AccountingContext();
            var tmp     = await context.Database.SqlQuery <ProductPrice>(
                $"select prod.ProductName ProductName,SUM(pip.Summ) Price from PayingItem as pi " +
                $"join PaiyngItemProduct as pip on pip.PayingItemID = pi.ItemID " +
                $"join Product as prod on prod.ProductID = pip.ProductID " +
                $"where pi.CategoryID = {catId} and pi.Date>='{dateFrom.Date}' and pi.Date<='{dateTo.Date}' " +
                $"group by prod.ProductName")
                          .ToListAsync();

            return(tmp);
        }
        public void Service__GetsAccountById()
        {
            // Arrange
            var id      = 49203841098409218UL;
            var account = GetMockAccount(id, "test_value1", 123, 123, true);

            var options = new DbContextOptionsBuilder <AccountingContext>()
                          .UseInMemoryDatabase(databaseName: "GetsAccountById")
                          .Options;

            // Act
            using (var context = new AccountingContext(options))
            {
                _service = new AccountService(context);
                context.Add(account);

                // Assert
                Assert.Equal(_service.Find(id), account);
            }
        }
Esempio n. 12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, AccountingContext context, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
                app.UseDatabaseErrorPage();
            }

            // global cors policy
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());
            app.UseAuthentication();
            app.UseMvc();

            CreateUserRoles(serviceProvider, context).Wait();
            DbInitializer.Initialize(context);
        }
        public void Service__UpdatesAccount()
        {
            // Arrange
            var id      = 49203841098409218UL;
            var hasCard = true;

            var oldName    = "test_value1";
            var oldFunds   = 123;
            var oldBalance = 456;

            var newName    = "test_value2";
            var newFunds   = 123123;
            var newBalance = 456456;

            var oldAccount = GetMockAccount(id, oldName, oldFunds, oldBalance, hasCard);
            var newAccount = GetMockAccount(id, newName, newFunds, newBalance, hasCard);

            var options = new DbContextOptionsBuilder <AccountingContext>()
                          .UseInMemoryDatabase(databaseName: "UpdatesAccount")
                          .Options;

            // Act
            using (var context = new AccountingContext(options))
            {
                _service = new AccountService(context);

                context.Add(oldAccount);
                context.SaveChanges();

                _service.Update(id, newAccount);

                var updatedAccount = context.Accounts.Find(id);

                // Assert
                Assert.Equal(newAccount.Name, updatedAccount.Name);
                Assert.Equal(newAccount.Balance, updatedAccount.Balance);
                Assert.Equal(newAccount.AvailableFunds, updatedAccount.AvailableFunds);
                Assert.Equal(newAccount.HasCard, updatedAccount.HasCard);
            }
        }
Esempio n. 14
0
        public void SaveBtn()
        {
            using (var ctx = new AccountingContext())
            {
                //Voucher stud = new Voucher() { ModeOfPayment = "Cash" };
                //ctx.Vouchers.Add(stud);

                Voucher fundClusterNumber = new Voucher()
                {
                    FundCluster         = _fundCluster,
                    DVNumber            = _dvNumber,
                    DateTIme1           = _dateTime1,
                    ModeOfPayment       = _modeOfPayment,
                    TinOrEmployeeNumber = _tinOrEmployeeNumber,
                    OrsOrBurs           = _orsOrBurs,
                    Particulars         = _particulars,
                    MFOPAP       = _mFOPAP,
                    Amount       = _amount1,
                    AccountTitle = _accountTitle,
                    UacsCode     = _uacsCode,
                    Debit        = _debit,
                    Credit       = _credit,
                    AFName       = _aFname,
                    AMName       = _aMName,
                    ALName       = _aLName,
                    AJobPosition = _aJobPosition,
                    CheckAda     = _checkAda,
                    DateTime2    = _dateTime2,
                    JevNumber    = _jevNo,
                    DateTim3     = _dateTime3
                };

                ctx.Vouchers.Add(fundClusterNumber);
                ctx.SaveChanges();
                ClearBtn();

                MessageBox.Show("Saved");
            }
        }
Esempio n. 15
0
        public void SaveIgp()
        {
            using (var ctx = new AccountingContext())
            {
                //Voucher stud = new Voucher() { ModeOfPayment = "Cash" };
                //ctx.Vouchers.Add(stud);

                IGPs igpInfo = new IGPs()
                {
                    IGPsName = _igpName,
                    IGPsZone = _igpName
                };



                //Voucher dvNumber = new Voucher() { DVNumber = _dvNumber };
                ctx.IGPss.Add(igpInfo);


                ctx.SaveChanges();

                ClearIgp();
            }
        }
Esempio n. 16
0
 public LoginController(IAcctRepo repo, ADContext adContext, AccountingContext accountingContext)
 {
     _repo              = repo;
     _adContext         = adContext;
     _accountingContext = accountingContext;
 }
Esempio n. 17
0
 public BankRepository(AccountingContext context)
 {
     this._context = context;
 }
Esempio n. 18
0
 public ApiController(AccountingContext context)
 {
     db = context;
 }
Esempio n. 19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AccountingContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            DbInitializer.Initialize(context);
        }
Esempio n. 20
0
 public SeedData(AccountingContext context, UserManager<AccountingUser> userManager, IHostingEnvironment env)
 {
     this.context = context;
     this.userManager = userManager;
     this.env = env;
 }
 public OperationsManager(AccountingContext db) : base(db)
 {
 }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccountingEntryRepository"/> class to the value indicated
 /// </summary>
 /// <param name="accountingContext">A <see cref="AccountingContext"/></param>
 public CurrencyRepository(AccountingContext accountingContext)
     : base(accountingContext)
     => _dbContext = accountingContext;
Esempio n. 23
0
 public AccountService(AccountingContext context) =>
Esempio n. 24
0
 public AccountingController(AccountingContext ctx)
 {
     this.db = ctx;
 }
Esempio n. 25
0
 public AccountController(AccountingContext context)
 {
     _context = context;
 }
Esempio n. 26
0
 public SoftSysBController(AccountingContext ctx)
 {
     this.db = ctx;
 }
Esempio n. 27
0
 public PaymentRepository(AccountingContext context)
 {
     this.context = context;
 }
Esempio n. 28
0
 public PositionEmployeeRepository(AccountingContext accountingContext)
 {
     _accountingContext = accountingContext;
 }
Esempio n. 29
0
 public AccountService(AccountingContext context)
 {
     _context = context;
 }
Esempio n. 30
0
 public ReceiptTypeRepository(AccountingContext context)
 {
     this._context = context;
 }
Esempio n. 31
0
 public SlipBook(AccountingContext context, IRepository <Domain.PaymentMethod> paymentMethods, ILogger <AccountingContext> logger)
 {
     this.context        = context;
     this.paymentMethods = paymentMethods;
     this.logger         = logger;
 }
Esempio n. 32
0
 public PaymentMethods(AccountingContext context)
 {
     this.context = context;
 }
 public CurrenciesManager(AccountingContext db) : base(db)
 {
 }