Esempio n. 1
0
 public ActionResult Edit([Bind(Include = "loanID,amount,interest,duration,customerID,locked")] Loan loan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerID = new SelectList(db.Customers, "customerID", "fName", loan.customerID);
     return(View(loan));
 }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "accountID,balance,type,interest,customerID,locked")] bankAccount bankAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bankAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerID = new SelectList(db.Customers, "customerID", "fName", bankAccount.customerID);
     return(View(bankAccount));
 }
        public async Task <IActionResult> PutAccount(Guid id, [FromBody] DepositRequest depositRequest)
        {
            try
            {
                //if (!RequestHelper.ValidateId(id, Request, _env))
                //    return BadRequest("HeaderId and Id are not equal");
                var account = await _context.Accounts.FirstOrDefaultAsync(x => x.OwnerId == id);

                account.Balance += depositRequest.Amount;

                _context.Entry(account).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                _rabbitMqClient.SendMessage(new HistoryMessage {
                    Event = "DepositedMoney", EventMessage = $"Deposited ${depositRequest.Amount} to own account", User = id, Timestamp = DateTime.UtcNow
                });
                _logger.LogInformation("Successfully deposited {Amount} to {@Account}", depositRequest.Amount, account);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to deposit money");
                throw;
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCustomer([FromRoute] long id, [FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.Id)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
        public ReturnObjValueBackEnd DeleteDealDetail(List <ChiTietGiaoDich> lstID)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();

            try
            {
                var ctx = new BankingContext();
                List <ChiTietGiaoDich> lst = new List <ChiTietGiaoDich>();
                for (int i = 0; i < lstID.Count; i++)
                {
                    lst.Add(new ChiTietGiaoDich {
                        MaKH = lstID[i].MaKH, NgayGD = lstID[i].NgayGD
                    });
                    ctx.Entry(lst[i]).State = System.Data.Entity.EntityState.Deleted;
                }
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
Esempio n. 6
0
        public ReturnObjValueBackEnd DeleteAccount(List <TaiKhoan> lstID)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();

            try
            {
                var             ctx = new BankingContext();
                List <TaiKhoan> lst = new List <TaiKhoan>();
                for (int i = 0; i < lstID.Count; i++)
                {
                    lst.Add(new TaiKhoan {
                        MaKH = lstID[i].MaKH,
                        MaNV = lstID[i].MaNV,
                        MaCN = lstID[i].MaCN
                    });
                    ctx.Entry(lst[i]).State = System.Data.Entity.EntityState.Deleted;
                }
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
Esempio n. 7
0
        public async Task <IHttpActionResult> PutClient(int id, Client client)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != client.Id)
            {
                return(BadRequest());
            }

            db.Entry(client).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 8
0
        public ReturnObjValueBackEnd DeleteStaff(List <string> lstMaNV)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();
            try
            {
                var             ctx   = new BankingContext();
                List <NhanVien> lstNV = new List <NhanVien>();
                for (int i = 0; i < lstMaNV.Count; i++)
                {
                    lstNV.Add(new NhanVien {
                        MaNV = lstMaNV[i]
                    });
                    ctx.Entry(lstNV[i]).State = System.Data.Entity.EntityState.Deleted;
                }
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
Esempio n. 9
0
        public ReturnObjValueBackEnd DeleteBanking(List <string> lstID)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();

            try
            {
                var ctx = new BankingContext();
                List <CreditManagement.Models.NganHang> lst = new List <CreditManagement.Models.NganHang>();
                for (int i = 0; i < lstID.Count; i++)
                {
                    lst.Add(new CreditManagement.Models.NganHang {
                        MaNH = lstID[i]
                    });
                    ctx.Entry(lst[i]).State = System.Data.Entity.EntityState.Deleted;
                }
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
Esempio n. 10
0
        public ReturnObjValueBackEnd DeleteCustomer(List <string> lstKH)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();
            try
            {
                var ctx = new BankingContext();
                List <KhachHang> lstKhachHang = new List <KhachHang>();
                for (int i = 0; i < lstKH.Count; i++)
                {
                    lstKhachHang.Add(new KhachHang {
                        MaKH = lstKH[i]
                    });
                    ctx.Entry(lstKhachHang[i]).State = System.Data.Entity.EntityState.Deleted;
                }
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
Esempio n. 11
0
 public override string ToString()
 {
     db.Entry(this).State = EntityState.Modified;
     db.SaveChanges();
     return("Nome: " + Nome +
            "CPF" + CPF +
            "RG" + RG);
 }
Esempio n. 12
0
 public ActionResult Edit([Bind(Include = "CustomerID,FirstName,LastName,UserName,UserPassword")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Esempio n. 13
0
 public ActionResult Edit([Bind(Include = "CPF,Nome,RG")] Pessoa pessoa)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pessoa).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pessoa));
 }
Esempio n. 14
0
 public ActionResult Edit([Bind(Include = "Id")] ContaContabilInvestimento contaContabilInvestimento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contaContabilInvestimento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contaContabilInvestimento));
 }
Esempio n. 15
0
 public ActionResult Edit([Bind(Include = "Id,numeroAgencia,numeroConta,senha,limite")] ContaCorrente contaCorrente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contaCorrente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contaCorrente));
 }
Esempio n. 16
0
 public ActionResult Edit([Bind(Include = "customerID,fName,lName,address,city,state,zip,DOB,tele,email,locked")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
 public ActionResult Edit([Bind(Include = "Id,tipoTaxa,valor,dataEntrada,dataResgate")] Investimento investimento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(investimento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(investimento));
 }
 public ActionResult Edit([Bind(Include = "Id,dataPagamento,dataEmprestimo,valor,formaPagamento,tipoTaxa")] Emprestimo emprestimo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emprestimo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emprestimo));
 }
Esempio n. 19
0
 public ActionResult Edit([Bind(Include = "cnpj,nome")] Banco banco)
 {
     if (ModelState.IsValid)
     {
         db.Entry(banco).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(banco));
 }
Esempio n. 20
0
 public ActionResult Edit([Bind(Include = "Id,numeroCC,descricao,valor,numeroDestino,data")] Movimentacao movimentacao)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movimentacao).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(movimentacao));
 }
 public ActionResult Edit([Bind(Include = "AccountID,Amount,CustomerID,Discriminator")] Account account)
 {
     if (ModelState.IsValid)
     {
         db.Entry(account).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", account.CustomerID);
     return(View(account));
 }
Esempio n. 22
0
 public ActionResult Edit([Bind(Include = "TransID,date,customerID,type,amount,employee")] TransHist transHist)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transHist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerID = new SelectList(db.Customers, "customerID", "fName", transHist.customerID);
     return(View(transHist));
 }
Esempio n. 23
0
 public ActionResult Edit([Bind(Include = "LoanID,Debt,InterestRate,DateCreated,CustomerID")] Loan loan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", loan.CustomerID);
     return(View(loan));
 }
Esempio n. 24
0
 public ActionResult Edit([Bind(Include = "TransactionID,TransactionDate,SignedCredit,AccountID,LoanID,TransactionDesc")] Transaction transaction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transaction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccountID = new SelectList(db.Accounts, "AccountID", "Discriminator", transaction.AccountID);
     ViewBag.LoanID    = new SelectList(db.Loans, "LoanID", "LoanID", transaction.LoanID);
     return(View(transaction));
 }
Esempio n. 25
0
 public void UpdateBankBranches(ChiNhanhNganHang objUpdate)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.Entry(objUpdate).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 26
0
 public void UpdateSaveMoney(SoTietKiem objUpdate)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.Entry(objUpdate).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 27
0
 public void UpdateDealDetail(ChiTietGiaoDich objUpdate)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.Entry(objUpdate).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 28
0
 public void UpdateAccount(TaiKhoan objUpdate)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.Entry(objUpdate).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 29
0
 public void UpdateStaff(NhanVien staff)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.Entry(staff).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 30
0
 public void UpdateCustomer(KhachHang customer)
 {
     try
     {
         using (var context = new BankingContext())
         {
             context.Entry(customer).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }