Blogboy2 0 Newbie Poster

his one i'm working c# try to use the account database from account to customerid and then the view which is page must have from account dropdown box and toaccount dropdown box and enter the amount the submit which result the amount is deducted from balance
I'm focusing on Account class has zero or one customers while Customer has many accounts
Account class
Accountid
Type
Balance
Customerid
Customer class
Customerid
name
description
address

Transfer funds page
fromaccount - dropdown box (accountid) toaccount - dropdown box(customerid) amount - input amount
submit
it will go to viewaccount page to show the balance has been deduct.
here is my logic code

Banking Project
ListAccounts.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<BankingProject.Account>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    ListAccounts
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>ListAccounts</h2>

    <table>
        <tr>
            <th></th>
            <th>
                AccountID
            </th>
            <th>
                Type
            </th>
            <th>
                Balance
            </th>
            <th>
                CustomerID
            </th>
        </tr>

    <% foreach (var item in Model) { %>

        <tr>
            <td>

            </td>
            <td>
                <%: item.AccountID %>
            </td>
            <td>
                <%: item.Type %>
            </td>
            <td>
                <%: item.Balance %>
            </td>
            <td>
                <%: item.CustomerID %>
            </td>
        </tr>

    <% } %>

    </table>



</asp:Content>
Homecontroller

 public ActionResult TransferFunds()
        {
            //ViewData["Account"] = new SelectList(_entities.Accounts, "AccountID", "AccountID");
            //ViewData["Customer"] = new SelectList(_entities.Accounts, "CustomerID", "CustomerID");

           // var balance = _entities.Accounts.A;

            return View();
            //http://microsoftmentalist.wordpress.com/2011/09/22/asp-net-mvc-16-html-textbox-and-html-textboxfor-helper-methods/
        }

        [HttpPost]
        public ActionResult Transfer(int amount)
        {
            if (ModelState.IsValid)
            {
                Account source = _entities.Accounts.Single(a => a.AccountID == a.AccountID);
                Account destination = _entities.Accounts.SingleOrDefault(a => a.CustomerID == a.CustomerID);
                //amount = Convert.ToInt32(_entities.Accounts.First(a => a.Balance == a.Balance));
                //int source = _entities.Accounts.Single(a => a.AccountID == a.AccountID);
               // int destination = _entities.Accounts.FirstOrDefault(a => a.CustomerID == a.CustomerID);
                  source.Balance -= amount;
                    destination.Balance += amount;

                    return RedirectToAction("Index");


                ModelState.AddModelError("Amount", "There's not enough money on your account.");
                return View();
            }
        }


        atm i'm using entitiesmodel

        dexter ho