private void ShowAllForm_Load(object sender, EventArgs e)
 {
     using (BankDbEntities bn = new BankDbEntities())
     {
         dataGridView1.DataSource = bn.udv_showtotalsummary.ToList();
     }
 }
コード例 #2
0
        public async Task <IHttpActionResult> Delete(int CustomerId)
        {
            using (BankDbEntities Db = new BankDbEntities())
            {
                try
                {
                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }

                    var loan = Db.Loan_Account.FirstOrDefault(l => l.CustomerId == CustomerId);
                    if (loan == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        Db.Loan_Account.Remove(loan);
                        await Db.SaveChangesAsync();

                        return(Ok("Deleted Loan Account "));
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest("Exception occured " + ex));
                }
            }
        }
コード例 #3
0
ファイル: User.cs プロジェクト: furkanozbx/BankSolution
 public User Get(int id)
 {
     using (BankDbEntities db = new BankDbEntities())
     {
         return(db.Users.Find(id));
     }
 }
コード例 #4
0
ファイル: User.cs プロジェクト: furkanozbx/BankSolution
 public User Get(Expression <Func <User, bool> > predicate)
 {
     using (BankDbEntities db = new BankDbEntities())
     {
         return(db.Users.Where(predicate).FirstOrDefault());
     }
 }
コード例 #5
0
 public async Task <HttpResponseMessage> GetParticularCustomerDataAsync(int customerId)
 {
     using (BankDbEntities Db = new BankDbEntities())
     {
         try
         {
             var task = Task.Run(() => Db.Saving_Account.Where(s => s.CustomerId == customerId).Select(s => new
             {
                 s.AccountNo,
                 s.CustomerId,
                 Name = s.FirstName + " " + s.LastName,
                 s.BranchCode,
                 s.PhoneNo,
                 s.CurrentBalance
             }).FirstOrDefault());
             var x = await task;
             //Saving_Account x = Db.Saving_Account.Where(s => s.CustomerId == customerId).FirstOrDefault();
             if (x == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "CustomerId " + customerId + " not found"));
             }
             else
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, x));
             }
         }
         catch (Exception e)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Exception Occured in executing GetParticularCustomerData " + e));
         }
     }
 }
コード例 #6
0
 public IHttpActionResult Delete(int customerId)
 {
     if (ModelState.IsValid)
     {
         using (BankDbEntities Db = new BankDbEntities())
         {
             var id = Db.Saving_Account.Where(s => s.CustomerId == customerId).FirstOrDefault();
             if (id == null)
             {
                 return(BadRequest("CustomerId with " + customerId + " not present"));
             }
             else
             {
                 var loan = Db.Loan_Account.FirstOrDefault(l => l.CustomerId == customerId);
                 if (loan != null)
                 {
                     Db.Loan_Account.Remove(loan);
                     Db.Saving_Account.Remove(id);
                     Db.SaveChanges();
                     return(Ok("Deleted Account Of " + id.FirstName + " " + id.LastName));
                 }
                 else
                 {
                     return(BadRequest("No loan with this customerId " + customerId));
                 }
             }
         }
     }
     else
     {
         return(BadRequest("Model is not valid"));
     }
 }
コード例 #7
0
 public IHttpActionResult Put([FromUri] int customerId, [FromBody] Saving_Account saving)
 {
     if (ModelState.IsValid)
     {
         using (BankDbEntities db = new BankDbEntities())
         {
             var id = db.Saving_Account.FirstOrDefault(s => s.CustomerId == customerId);
             if (id == null)
             {
                 return(NotFound());
             }
             else
             {
                 id.AccountNo      = saving.AccountNo;
                 id.BranchCode     = saving.BranchCode;
                 id.CurrentBalance = saving.CurrentBalance;
                 id.EmailId        = saving.EmailId;
                 id.FirstName      = saving.FirstName;
                 id.LastName       = saving.LastName;
                 id.PhoneNo        = saving.PhoneNo;
                 db.SaveChanges();
                 return(Ok("Sucessfully Altered"));
             }
         }
     }
     else
     {
         return(BadRequest("Not a valid Model"));
     }
 }
コード例 #8
0
 private void TakeCreditForm_Load(object sender, EventArgs e)
 {
     using (BankDbEntities bn = new BankDbEntities())
     {
         List <Customer> customers = bn.Customers.Where(x => x.Id > 0).ToList();
         comboBox1.Items.Add(bn.Customers.ToList().Last().Name);
     }
 }
コード例 #9
0
 public void SaveData(Loan_Account loan)
 {
     using (BankDbEntities Db = new BankDbEntities())
     {
         var s = Db.Saving_Account.Where(l => l.CustomerId == loan.CustomerId).FirstOrDefault();
         if (s != null)
         {
             loan.CustomerId = s.CustomerId;
             Db.Loan_Account.Add(loan);
             Db.SaveChanges();
         }
     }
 }
コード例 #10
0
        public async Task <IHttpActionResult> PostSavingData([FromBody] Saving_Account saving)
        {
            if (ModelState.IsValid)
            {
                using (BankDbEntities Db = new BankDbEntities())
                {
                    Db.Saving_Account.Add(saving);
                    var x = await Db.SaveChangesAsync();

                    return(Ok("Added account " + x));
                }
            }
            else
            {
                return(BadRequest("Model is not valid"));
            }
        }
コード例 #11
0
 public IHttpActionResult Get()
 {
     using (BankDbEntities Db = new BankDbEntities())
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest("Bad Request"));
         }
         var loan = Db.Loan_Account.Select(l => new Loan()
         {
             CustomerId     = (int)l.CustomerId,
             Loan_AccountNo = l.Loan_AccountNo,
             LoanAmount     = (int)l.LoanAmount,
             Loan_Int_Type  = l.Loan_Int_Type,
             Loan_Term      = (int)l.Loan_Term
         }).ToList();
         return(Ok(loan));
     }
 }
コード例 #12
0
 private void btb_addcredit_Click(object sender, EventArgs e)
 {
     using (BankDbEntities bn = new BankDbEntities())
     {
         try
         {
             if (comboBox1.Text != "" && textBox1.Text != null)
             {
                 bn.usp_Givecredit(comboBox1.SelectedItem.ToString(), Convert.ToInt32(textBox1.Text), dateTimePicker1.Value, bn.Customers.ToList().Last().Id);
                 ShowAllForm showAllForm = new ShowAllForm();
                 showAllForm.ShowDialog();
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #13
0
 public async Task <IHttpActionResult> Put([FromUri] int customerId, [FromBody] Loan_Account loan)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Not a valid Model"));
     }
     using (BankDbEntities Db = new BankDbEntities())
     {
         var existingloan = Db.Loan_Account.FirstOrDefault <Loan_Account>(l => l.CustomerId == customerId);
         if (existingloan != null)
         {
             existingloan.LoanAmount     = loan.LoanAmount;
             existingloan.Loan_AccountNo = loan.Loan_AccountNo;
             await Db.SaveChangesAsync();
         }
         else
         {
             NotFound();
         }
     }
     return(Ok());
 }
コード例 #14
0
 public async Task <IHttpActionResult> PostLoanData(Loan_Account loan)
 {
     using (BankDbEntities Db = new BankDbEntities())
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var task = Task.Run(() => Db.Saving_Account.Where(s => s.CustomerId == loan.CustomerId).FirstOrDefault());
         var id   = await task;
         if (id != null)
         {
             Db.Loan_Account.Add(loan);
             Db.SaveChanges();
             return(Ok("Data Added"));
         }
         else
         {
             return(BadRequest("CustomerId Not Exist Loan cannot be initiated"));
         }
     }
 }
コード例 #15
0
 public IHttpActionResult GetSavingData()
 {
     if (ModelState.IsValid)
     {
         using (BankDbEntities Db = new BankDbEntities())
         {
             /*var saving = Db.Saving_Account.Select(s => new Saving()
              * {
              *  AccountNo = s.AccountNo,
              *  Name = s.FirstName +" "+ s.LastName,
              *  EmailId = s.EmailId,
              *  PhoneNo = s.PhoneNo,
              *  CurrentBalance = s.CurrentBalance
              * }).ToList();*/
             /*Using Anonymous*/
             var saving = Db.Saving_Account.Select(s => new
             {
                 s.CustomerId,
                 s.AccountNo,
                 Name = s.FirstName + " " + s.LastName,
                 s.EmailId,
                 s.PhoneNo,
                 s.BranchCode,
                 s.CurrentBalance
             }).ToList();
             if (saving.Count == 0)
             {
                 return(Ok("No Saving Account"));
             }
             return(Ok(saving));
         }
     }
     else
     {
         return(BadRequest("Model is not valid"));
     }
 }
コード例 #16
0
        public List <Loan_Account> GetData()
        {
            using (BankDbEntities Db = new BankDbEntities())
            {
                var loan = Db.Loan_Account.ToList();
                if (loan.Count == 0)
                {
                    return(null);
                }
                else
                {
                    return(loan);
                }

                /*
                 * Select(l => new
                 * {
                 *  l.CustomerId,
                 *  l.Loan_AccountNo,
                 *  l.LoanAmount,
                 *  l.Loan_Term
                 * }).*/
            }
        }