protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect("~/Account/Login");
            }

            var userId = User.Identity.GetUserId();

            var data = new AccountSystemData(new AccountSystemDbContext());

            var accounts = data.Accounts.All().Where(x => x.OwnerId == userId).ToList();

            AccountsRepeater.DataSource = accounts;
            AccountsRepeater.DataBind();
        }
Exemplo n.º 2
0
        protected void CreateAccount_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var curType = (CurrencyType)Enum.Parse(typeof(CurrencyType), CurTypeList.SelectedValue, true);

                var newAccount = new BankAccount()
                {
                    Balance = decimal.Parse(BalanceField.Text), CurrencyType = curType, OwnerId = userId, Status = AccountStatus.Active
                };
                var data = new AccountSystemData(new AccountSystemDbContext());
                data.Accounts.Add(newAccount);
                data.SaveChanges();

                Response.Redirect("/Users/Admin/UserDetails?id=" + userId);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.IsInRole("Admin"))
            {
                Response.Redirect("/");
            }

            var userId = User.Identity.GetUserId();

            var data = new AccountSystemData(new AccountSystemDbContext());

            adminRoleId = data.Roles.All().FirstOrDefault(r => r.Name == "Admin").Id;
            var users = this.GetClients()
                        .Select(u => new { Username = u.UserName, Id = u.Id, Email = u.Email, TotalBalance = u.Accounts.Sum(a => a.Balance) })
                        .ToList();

            UsersRepeater.DataSource = users;
            UsersRepeater.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.IsInRole("Admin"))
            {
                Response.Redirect("/");
            }

            userId = Request.QueryString["id"];
            if (userId == null)
            {
                Response.Redirect("/");
            }

            var data = new AccountSystemData(new AccountSystemDbContext());

            username = data.Users.Find(userId).UserName;
            var accounts = data.Accounts.All().Where(x => x.OwnerId == userId).ToList();

            AccountsRepeater.DataSource = accounts;
            AccountsRepeater.DataBind();
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.IsInRole("Client"))
            {
                ibanId = Request.QueryString["id"];
                if (ibanId == null)
                {
                    Response.Redirect("/");
                }

                var data = new AccountSystemData(new AccountSystemDbContext());

                var account = data.Accounts.All().Where(x => x.IBAN.ToString() == ibanId).FirstOrDefault();

                if (account == null)
                {
                    Response.Redirect("/Users/Details");
                }

                if (account.OwnerId != User.Identity.GetUserId())
                {
                    Response.Redirect("/");
                }

                LiteralCurrency.Text = account.CurrencyType.ToString();
                LiteralBalance.Text  = account.Balance.ToString();
                LiteralOwner.Text    = account.Owner.UserName;
                LabelStatus.Text     = account.Status.ToString();
                var userCards = account.Owner.Cards.ToList();
            }

            else
            {
                Response.Redirect("/");
            }
        }