public IHttpActionResult PutCustomer(decimal id, Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutAccount_Holder(decimal id, Account_Holder account_Holder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != account_Holder.account_no)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Account_HolderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutTransaction(string id, Transaction transaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != transaction.ref_id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TransactionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
        public IHttpActionResult PutBeneficiary(decimal id, Beneficiary beneficiary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != beneficiary.ben_id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BeneficiaryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 5
0
        public ActionResult Create(/*[Bind(Include = "Id,UserId,OpenDate,CloseDate,Active,Balance,InterestRate")]*/ Models.CheckingAccountViewModel cavm)
        {
            if (ModelState.IsValid)
            {
                var UserId          = Convert.ToInt32(Session["UserId"]);
                var DT              = DateTime.Now;
                var CheckingAccount = new CheckingAccount
                {
                    UserId       = UserId,
                    Balance      = cavm.Balance,
                    Customer     = db.Customers.SingleOrDefault(cust => cust.Id == UserId),
                    OpenDate     = DT,
                    Active       = true,
                    InterestRate = 1.05m
                };
                db.CheckingAccounts.Add(CheckingAccount);
                db.SaveChanges();
                db.Transactions.Add(
                    new Transaction
                {
                    Amount      = cavm.Balance,
                    DateTime    = DT,
                    AccountType = CheckingAccount.Text,
                    Description = "Opening Deposit",
                    AccountId   = CheckingAccount.Id
                }
                    );
                db.SaveChanges();
                return(RedirectToAction("Details", new { id = CheckingAccount.Id }));
            }

            //ViewBag.UserId = new SelectList(db.Customers, "Id", "Email", checkingAccount.UserId);
            return(View(cavm));
        }
Exemplo n.º 6
0
        public ActionResult Create(/*[Bind(Include = "Id,Email,Password,Address1,Address2,City,Zip,Phone,OpenDate,CloseDate,Active")]*/ Customer customer)
        {
            //var EmailVerify = db.Customers.Count(q => q.Email == customer.Email);
            var EmailVerify = db.Customers.SingleOrDefault(q => q.Email == customer.Email);

            if (EmailVerify == null)
            {
                if (ModelState.IsValid)
                {
                    //Form validation is good. Insert customer and set session var
                    customer.OpenDate = DateTime.Now;
                    db.Customers.Add(customer);
                    db.SaveChanges();
                    var Customers = db.Customers.ToList();
                    var Customer  = Customers.Find(c => c.Id == customer.Id);
                    Session["UserId"]   = Convert.ToString(Customer.Id);
                    Session["Password"] = Convert.ToString(Customer.Password);
                    return(RedirectToAction("Details", Customer.Id));
                }
            }
            else
            {
                ViewBag.ValidationSummary = "Email is in use. Did you forget your password?";
            }
            return(View());
        }
Exemplo n.º 7
0
 public ActionResult Create(/*[Bind(Include = "Id,UserId,OpenDate,CloseDate,Active,Balance")]*/ Models.BusinessAccountCreateViewModel businessAccount)
 {
     Debug.WriteLine("Reached create post");
     if (ModelState.IsValid)
     {
         using (var dbContextTransaction = db.Database.BeginTransaction())
         {
             int BAId = 0;
             try
             {
                 Debug.WriteLine(businessAccount.OpeningDeposit);
                 var NewBusiness = new BusinessAccount
                 {
                     Balance  = Convert.ToInt32(businessAccount.OpeningDeposit),
                     Active   = true,
                     OpenDate = DateTime.Now,
                     UserId   = Convert.ToInt32(Session["UserId"])
                 };
                 db.BusinessAccounts.Add(NewBusiness);
                 db.SaveChanges();
                 BAId = NewBusiness.Id;
                 db.Transactions.Add(
                     new Transaction
                 {
                     Description = "Opening Deposit",
                     AccountType = "banking",
                     Amount      = NewBusiness.Balance,
                     DateTime    = NewBusiness.OpenDate,
                     AccountId   = BAId
                 });
                 db.SaveChanges();
                 dbContextTransaction.Commit();
             }
             catch (Exception)
             {
                 dbContextTransaction.Rollback();
             }
             db.SaveChanges();
             if (BAId != 0)
             {
                 return(RedirectToAction("Details", new { id = BAId }));
             }
             //return RedirectToAction("Index");
         }
     }
     //ViewBag.UserId = new SelectList(db.Customers, "Id", "Email", businessAccount.UserId);
     return(View(businessAccount));
 }