public async Task <IActionResult> Edit(int id, [Bind("SellerId,AccountId,AverageRating")] SellerAccount sellerAccount)
        {
            if (id != sellerAccount.SellerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sellerAccount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SellerAccountExists(sellerAccount.SellerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountId"] = new SelectList(_context.Accounts, "AccountId", "Email", sellerAccount.AccountId);
            return(View(sellerAccount));
        }
Exemplo n.º 2
0
        public async Task RegisterAndLoginAccount_UpgradeToSellerAccount()
        {
            //Arrange
            AccountsController accountsController = new AccountsController(context, hostEnvironment);
            AccountViewModel   accountViewModel   = AccountRegistration();
            LoginViewModel     loginViewModel     = AccountLogin(accountViewModel);
            SellerAccount      sellerAccount      = new SellerAccount();

            SellerAccountsController sellerAccountsController = new SellerAccountsController(context, hostEnvironment);

            //Act
            accountsController.Create(accountViewModel);
            accountsController.Login(loginViewModel);

            try
            {
                //Assert
                if (accountsController.ModelState.IsValid)
                {
                    await sellerAccountsController.Create(sellerAccount);

                    Assert.True(accountsController.ModelState.IsValid && sellerAccountsController.ModelState.IsValid);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 3
0
        void InitializeSeller()
        {
            SellerAccount seller = new SellerAccount
            {
                AccountId     = 0,
                AverageRating = 0,
                Account       = InitializeAccount()
            };

            context.Add(seller);
        }
        public async Task <IActionResult> Create([Bind("SellerId,AccountId,AverageRating")] SellerAccount sellerAccount)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sellerAccount);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountId"] = new SelectList(_context.Accounts, "AccountId", "Email", sellerAccount.AccountId);
            return(View(sellerAccount));
        }
Exemplo n.º 5
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     try
     {
         AnbarDataContext Bank = new AnbarDataContext();
         SellerAccount    objTableSellerAccount = new SellerAccount();
         objTableSellerAccount.EnterID  = Convert.ToInt64(textBox1.Text);
         objTableSellerAccount.Date     = lbl_DateFact.Text;
         objTableSellerAccount.Debit    = Convert.ToInt64(textBox3.Text);
         objTableSellerAccount.Creditor = 0;
         Bank.SellerAccounts.InsertOnSubmit(objTableSellerAccount);
         Bank.SubmitChanges();
         MessageBox.Show("Commit Transaction.");
     }
     catch
     {
         MessageBox.Show("Rollback Transaction.");
     }
 }
Exemplo n.º 6
0
 public override bool IsValid()
 {
     if (!base.IsValid())
     {
         return(false);
     }
     if (TransactionStyle != TransferType.BuyAccount)
     {
         return(true);
     }
     if (AccountPrice < 0)
     {
         return(false);
     }
     if (!SellerAccount.IsValid())
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
        public async Task <IActionResult> Upgrade(UpgradeViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Code == HttpContext.Session.GetString("emailCode"))
                {
                    SellerAccount sellerAccount = new SellerAccount();
                    sellerAccount.AccountId = Int32.Parse(HttpContext.Session.GetString("userId"));
                    HttpContext.Session.SetInt32("sellerId", sellerAccount.SellerId);

                    SellerAccountsController sellerAccountsController = new SellerAccountsController(_context, _hostEnvironment);
                    await sellerAccountsController.Create(sellerAccount);

                    return(View("UpgradeSuccess"));
                }
                ModelState.AddModelError("", "Code is invalid");
            }
            ModelState.AddModelError("", "Invalid Attempt");
            return(View(model));
        }