Example #1
0
 public void AcceptButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (var repo = new AccountRepo())
         {
             if (a == null)
             {
                 repo.Add(new Account()
                 {
                     Name          = accountNameBox.Text,
                     CurrentAmount = double.Parse(accountCurrAmountBox.Text),
                     IconID        = imageComboBox1.SelectedIndex
                 });
             }
             else
             {
                 a.Name          = Name = accountNameBox.Text;
                 a.CurrentAmount = double.Parse(accountCurrAmountBox.Text);
                 a.IconID        = imageComboBox1.SelectedIndex;
                 repo.Save(a);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (string.IsNullOrEmpty(SessionPersister.Username))
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Account", Action = "Index" }));
            }
            else
            {
                //AccountRepo ar = new AccountRepo();
                //CustomPrincipal mp = new CustomPrincipal(ar.find(SessionPersister.Username));
                //if (!mp.IsInRole(Roles))

                //    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }));
                CustomPrincipal cp = new CustomPrincipal(AccountRepo.GetAccessRightByRole(SessionPersister.Username, Roles));
                //CustomPrincipal cp1 = new CustomPrincipal(AccountRepo.GetAccessRight(SessionPersister.Username, Roles));
                var level = AccountRepo.GetAccessRight(SessionPersister.Username, Roles);

                if (!cp.IsInRole(Roles))
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }));
                }
                else
                {
                    if (level.AccessLevel != this.AccessLevel && this.AccessLevel != null)
                    {
                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }));
                    }
                }
            }
        }
Example #3
0
        public void DelButton_Click(object sender, EventArgs e)
        {
            var a = accountDataGrid.CurrentRow?.DataBoundItem as Account;

            if (a == null)
            {
                return;
            }
            if (MessageBox.Show(@"Видалити обране поле?", @"Видалення", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
                DialogResult.OK)
            {
                try
                {
                    using (var repo = new AccountRepo())
                    {
                        repo.Delete(a);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                UpdateGrid();
            }
        }
        //Have to delete all child tables that have the userID tied to it first.
        //NEED TO FIX THE REMOVE ACCOUNT FUNCTION IN ACCOUNT REPO
        public ActionResult DeleteAccount(int id)
        {
            AccountRepo accounts = new AccountRepo();

            accounts.RemoveAccount(id);
            return(RedirectToAction("ListAccounts"));
        }
Example #5
0
        /// <summary>
        /// Event handler for the 'Add transaction' button
        /// </summary>
        /// <remarks>
        /// Fills a transaction and inserts it in the database </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ButtonAddTransaction_Click(object sender, RoutedEventArgs e)
        {
            if (!Utils.IsValid(TransactionGrid))
            {
                MessageBox.Show("Transaction is not valid");
                return;
            }

            // Get selected account
            Account selectedAccount;

            using (var repo = new AccountRepo())
            {
                selectedAccount = repo.GetAccountByConcept((String)AccountComboBox.SelectedItem);
            }

            // Creates transaction
            // TODO: this should use the Transaction created in the constructor
            Transaction transaction = new EF.Transaction()
            {
                Date = DatePicker.DisplayDate, Value = Convert.ToDecimal(textValue.Text), Concept = textConcept.Text, Account = selectedAccount
            };

            using (var repo = new TransactionRepo())
            {
                repo.Add(transaction);
            }

            this.Close();
        }
Example #6
0
        public IHttpActionResult SetBio([FromBody] JObject request)
        {
            Account        user = request.ToObject <Account>();
            Repo <Account> cr   = new AccountRepo();

            cr.Update(user);
            return(Ok());
        }
Example #7
0
        public IHttpActionResult GetAvatar([FromBody] JObject request)
        {
            Account        user = request.ToObject <Account>();
            Repo <Account> cr   = new AccountRepo();

            user = cr.Read(user);
            return(Ok(user.Avatar));
        }
Example #8
0
        public void outlayAddButton_Click(object sender, EventArgs e)
        {
            var      a  = outlayAccountComboBox.SelectedItem as Account;
            var      p  = outlayPersonComboBox.SelectedItem as Person;
            var      t  = outlayTypeComboBox.SelectedItem as Type;
            DateTime dt = outlayDatePicker.Value;

            try
            {
                if (o == null)
                {
                    using (var repo = new OutlayRepo())
                    {
                        repo.Add(new Outlay()
                        {
                            Account_ID = a.ID,
                            Day        = dt.Day,
                            Month      = dt.Month,
                            Year       = dt.Year,
                            Person_ID  = p.ID,
                            Type_ID    = t.ID,
                            Value      = double.Parse(outlayValueBox.Text),
                            Comment    = outlayCommentBox.Text
                        });
                    }
                    using (var repo = new AccountRepo())
                    {
                        a.CurrentAmount -= double.Parse(outlayValueBox.Text);
                        repo.Save(a);
                    }
                }
                else
                {
                    using (var repo = new AccountRepo())
                    {
                        a.CurrentAmount += o.Value;
                        a.CurrentAmount -= double.Parse(outlayValueBox.Text);
                        repo.Save(a);
                    }
                    using (var repo = new OutlayRepo())
                    {
                        o.Account_ID = a.ID;
                        o.Day        = dt.Day;
                        o.Month      = dt.Month;
                        o.Year       = dt.Year;
                        o.Person_ID  = p.ID;
                        o.Type_ID    = t.ID;
                        o.Value      = double.Parse(outlayValueBox.Text);
                        o.Comment    = outlayCommentBox.Text;
                        repo.Save(o);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #9
0
        public void incomeAddButton_Click(object sender, EventArgs e)
        {
            var      a  = incomeAccountComboBox.SelectedItem as Account;
            var      p  = incomePersonComboBox.SelectedItem as Person;
            var      t  = incomeTypeComboBox.SelectedItem as Type;
            DateTime dt = incomeDatePicker.Value;

            try
            {
                if (i == null)
                {
                    using (var repo = new IncomeRepo())
                    {
                        repo.Add(new Income()
                        {
                            Account_ID = a.ID,
                            Day        = dt.Day,
                            Month      = dt.Month,
                            Year       = dt.Year,
                            Person_ID  = p.ID,
                            Type_ID    = t.ID,
                            Value      = double.Parse(incomeValueBox.Text),
                            Comment    = incomeCommentBox.Text
                        });
                    }
                    using (var repo = new AccountRepo())
                    {
                        a.CurrentAmount += double.Parse(incomeValueBox.Text);
                        repo.Save(a);
                    }
                }
                else
                {
                    using (var repo = new AccountRepo())
                    {
                        a.CurrentAmount -= i.Value;
                        a.CurrentAmount += double.Parse(incomeValueBox.Text);
                        repo.Save(a);
                    }
                    using (var repo = new IncomeRepo())
                    {
                        i.Account_ID = a.ID;
                        i.Day        = dt.Day;
                        i.Month      = dt.Month;
                        i.Year       = dt.Year;
                        i.Person_ID  = p.ID;
                        i.Type_ID    = t.ID;
                        i.Value      = double.Parse(incomeValueBox.Text);
                        i.Comment    = incomeCommentBox.Text;
                        repo.Save(i);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        public void Delete_An_Exisitng_Account_Removes_Account()
        {
            var fakeReaderWriter = A.Fake <IReaderWriter>();

            A.CallTo(() => fakeReaderWriter.ReadEnumerable <Account>(_path)).Returns(_accounts);

            var accountRepo = new AccountRepo(fakeReaderWriter, _path);
            var accountGuid = accountRepo.DeleteMoneyAccount(_account.AccountGuid);
        }
        public IActionResult Get()
        {
            var userFromAuth = UserService.GetUserFromClaims(this.User, UserRepo, RequestLogger);

            RequestLogger.UserId = userFromAuth.Id.ToString();

            var accounts = AccountRepo.FindAllByOwner(userFromAuth.Id);

            return(Ok(CleanDoubleReferences(accounts)));
        }
        // [Authorize(Roles = "ExternalQuotes:6, ExternalQuotes:5, ExternalQuotes:12, ExternalQuotes:13, ExternalQuotes:15, ExternalQuotes:16, ExternalQuotes:10, ExternalQuotes:11")]
        public IEnumerable <BaseAccount> GetAll()
        {
            MainAccountRepo _mainAccountRepo = new MainAccountRepo(_context);
            AccountRepo     _accountRepo     = new AccountRepo(_context);

            _repo.getAll();
            _mainAccountRepo.getAll();
            _accountRepo.getAll();
            return(_repo.getAll());
        }
 Employee emp; //new
 public Accounts(Login l)
 {
     InitializeComponent();
     this.l            = l;
     ar                = new AccountRepo();
     emp               = new Employee(); //new
     Totaltb.Visible   = false;
     totallbl.Visible  = false;
     Deletebtn.Enabled = false;
 }
        public bool CreateAccount(string mobileNumber, string firstName, string lastName, string dateOfBirth, string gender, string email)
        {
            AccountRepo accountRepo = new AccountRepo();

            if (accountRepo.CreateAccount(mobileNumber, firstName, lastName, dateOfBirth, gender, email).Equals(false))
            {
                return(false);
            }

            return(true);
        }
Example #15
0
        public void Create_An_Account_Will_Add_Account()
        {
            var fakeReaderWriter = A.Fake <IReaderWriter>();

            A.CallTo(() => fakeReaderWriter.ReadEnumerable <Account>(_path)).Returns(null);

            var accountRepo = new AccountRepo(fakeReaderWriter, _path);
            var accountGuid = accountRepo.CreateMoneyAccount(_account.AccountName);

            Assert.That(_account.AccountName, Is.EqualTo(accountRepo.GetMoneyAccount(accountGuid).AccountName));
        }
        public IActionResult Put([FromBody] AllAccountsOverview allAccounts)
        {
            var userFromAuth = UserService.GetUserFromClaims(this.User, UserRepo, RequestLogger);

            RequestLogger.UserId = userFromAuth.Id.ToString();

            AccountRepo.UpsertAccountChanges(allAccounts, userFromAuth.UserName);
            var newAllAccounts = AccountService.GetAllAccountsOverview(userFromAuth.Id, allAccounts.RelevantYear, allAccounts.RelevantMonth);

            return(Ok(newAllAccounts));
        }
Example #17
0
        public void Broadcast(Message m)
        {
            Repo <Account>        userRepo = new AccountRepo();
            ICollection <Account> users    = userRepo.ReadAll();

            foreach (var user in users)
            {
                m.To = user;
                user.AddMessageToInbox(m);
            }
        }
Example #18
0
        public AccountController(IConfiguration iconfiguration)
        {
            string con = iconfiguration.GetSection("ConnectionStrings").GetSection("connectionstring").Value;

            iaccountcontext = new AccountMsSqlContext(con);
            accountrepo     = new AccountRepo(iaccountcontext);

            inotificationcontext = new NotificationMsSqlContext(con);
            notificationrepo     = new NotificationRepo(inotificationcontext);

            accVeri = new AccountVerification();
        }
Example #19
0
        public HomeController(IConfiguration iconfiguration)
        {
            string con = iconfiguration.GetSection("ConnectionStrings").GetSection("connectionstring").Value;

            iappointmentContext = new AppointmentMsSqlContext(con);
            appointmentrepo     = new AppointmentRepo(iappointmentContext);

            iaccountcontext = new AccountMsSqlContext(con);
            accountrepo     = new AccountRepo(iaccountcontext);

            accVeri = new AccountVerification();
        }
 public AccountController(AccountRepo ar,
                          UserManager <ApplicationUser> userManager,
                          SignInManager <ApplicationUser> signInManager,
                          IOptions <JWTSettings> optionsAccessor,
                          SubletRepo sr)
 {
     _accountRepo   = ar;
     _userManager   = userManager;
     _signInManager = signInManager;
     _options       = optionsAccessor.Value;
     _subletRepo    = sr;
 }
Example #21
0
 public AdminController(IHttpContextAccessor httpContextAccessor, ApplicationDbContext context,
                        IHostingEnvironment hostingEnvironment)
 {
     this._httpContextAccessor = httpContextAccessor;
     _hostingEnvironment       = hostingEnvironment;
     this._context             = context;
     this.cr = new CategoryRepo(context);
     this.gr = new GoodsRepo(context);
     this.ar = new AccountRepo(context);
     this.ag = new AccountGoodsRepo(context);
     this.og = new OrderRepo(context);
 }
Example #22
0
 public void DeleteOperation(object sender, EventArgs e)
 {
     if (_currentGridView == 0)
     {
         return;
     }
     if (_currentGridView == 1)
     {
         var i = incomeDataGridView.CurrentRow?.DataBoundItem as Income;
         if (i == null)
         {
             return;
         }
         if (MessageBox.Show(@"Видалити обране поле?", @"Видалення", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
             DialogResult.OK)
         {
             using (var repo = new AccountRepo())
             {
                 var a = repo.GetOne(_currentAccount);
                 a.CurrentAmount -= i.Value;
                 repo.Save(a);
             }
             using (var repo = new IncomeRepo())
             {
                 repo.Delete(i);
             }
         }
     }
     else
     {
         var o = outlayDataGridView.CurrentRow?.DataBoundItem as Outlay;
         if (o == null)
         {
             return;
         }
         if (MessageBox.Show(@"Видалити обране поле?", @"Видалення", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
             DialogResult.OK)
         {
             using (var repo = new AccountRepo())
             {
                 var a = repo.GetOne(_currentAccount);
                 a.CurrentAmount -= o.Value;
                 repo.Save(a);
             }
             using (var repo = new OutlayRepo())
             {
                 repo.Delete(o);
             }
         }
     }
     UpdateForm();
 }
        public void Test_InsertAccount_OpensAndClosesConneciton_Passes()
        {
            // Setup
            IAccountRepo accountRepo = new AccountRepo(componentsMock);
            Account      a           = new Account();

            // Action
            accountRepo.InsertAccount(a);

            // Assert
            Assert.IsTrue(connectionMock.connectionOpened);
            Assert.IsTrue(connectionMock.connectionClosed);
        }
Example #24
0
        public void ShouldUseRetryLogic()
        {
            var acctRepo     = new AccountRepo();
            var acctXferRepo = new AccountTransactionRepo();
            var accounts     = acctRepo.GetAll();
            var xferCount    = acctXferRepo.GetAll().Count;
            var xfer         = new AccountTransaction {
                Account = accounts[1], Amount = -100
            };
            var ex = Assert.Throws <RetryLimitExceededException>(() => acctXferRepo.Add(xfer));

            acctXferRepo.GetAll().Count.ShouldEqual(xferCount);
        }
 public HomeController(IHttpContextAccessor httpContextAccessor, ApplicationDbContext context, UserManager <ApplicationUser> userManager)
 {
     this._httpContextAccessor = httpContextAccessor;
     this._context             = context;
     // this._http = http;
     this.cr       = new CategoryRepo(context);
     this.gr       = new GoodsRepo(context);
     this.ar       = new AccountRepo(context);
     this.ag       = new AccountGoodsRepo(context);
     this.cartRepo = new CartRepo(context);
     this.amazon   = new AmazonPriceScrapy(_context);
     _userManager  = userManager;
 }
        public void Test_InsertAccount_UsesTransactionAndCommits_Passes()
        {
            // Setup
            IAccountRepo accountRepo = new AccountRepo(componentsMock);
            Account      a           = new Account();

            // Action
            accountRepo.InsertAccount(a);

            // Assert
            Assert.IsTrue(connectionMock.transactionUsed);
            Assert.IsTrue(connectionMock.transaction.commited);
        }
Example #27
0
        public AddTransactionWindow()
        {
            InitializeComponent();

            using (var repo = new AccountRepo())
            {
                AccountComboBox.ItemsSource = repo.GetAllConcepts();
            }
            // Creates new Transaction for Binding and validation
            this.DataContext = new EF.Transaction()
            {
                Date = DateTime.Now
            };
        }
Example #28
0
        public void ShouldDoBulkCopy()
        {
            var accountId = new AccountRepo().GetFirst().Id;
            var xfers     = new List <AccountTransaction>();

            for (int x = 0; x < 100; x++)
            {
                xfers.Add(new AccountTransaction {
                    AccountID = accountId, Amount = 100, TransactionDate = DateTime.Now
                });
            }
            ExecuteBulkCopy.ImportRecordsToSQL(xfers);
            new AccountTransactionRepo().GetAll().Count.ShouldEqual(100);
        }
Example #29
0
        public void Put([FromBody] Account account)
        {
            var accountRepo = new AccountRepo(_context);

            if (account != null && account.Id != Guid.Empty)
            {
                var record = accountRepo.Repo.GetByID(account.Id);
                if (record == null)
                {
                    accountRepo.Repo.Insert(account);
                }
                accountRepo.Save();
            }
        }
        public void Test_UpdateAccount_UsesCommit_Passes()
        {
            // TODO: fix
            // Setup
            IAccountRepo accountRepo = new AccountRepo(componentsMock);
            Account      a           = new Account();
            Account      b           = new Account();

            // Action
            accountRepo.UpdateAccount(a);

            // Assert
            Assert.IsTrue(connectionMock.transaction.commited);
        }