美文网首页
2018-04-10 开胃学习.Net 系列 - MVC作业2

2018-04-10 开胃学习.Net 系列 - MVC作业2

作者: Kaiweio | 来源:发表于2018-04-11 00:24 被阅读0次
    1. 【待解决】 如果我在 route.config 里修改了 transaction的create,之后会怎么样???

    作业细节要求

    A bank accounts listing with URL suffix /Bank/Account/List, shows all of the accounts presently open.
    The user should see this screen upon first logging in.
    The listing should show the name of the account, account number and current balance of each one (see create account screen below for details), as well as a link that navigates the user to the account details screen for that account (see below), and a link that deletes the account /Bank/Account/Delete/{id}.
    See Html.ActionLink and the Visual Studio scaffolding features for ideas on implementing these links. The user should be asked to confirm the deletion first.

    1. 【已完成】都要先登录再操作
    2. 【已完成】URL后缀 /Bank/Account/List ,其中设置的name就是在Html.ActionLink 会使用到的参数
                routes.MapRoute(
                  name: "Index",
                  url: "Bank/Account/List",
                  defaults: new { controller = "BankAccounts", action = "Index", id = UrlParameter.Optional }
              );
    
    1. 【已完成】 /Bank/Account/Delete/{id} ,id应该就是创建时候的 PK*
                routes.MapRoute(
                  name: "Delete",
                  url: "Bank/Account/Delete/{id}",
                  defaults: new { controller = "BankAccounts", action = "Delete", id = UrlParameter.Optional }
              );
    
    1. 【已完成】显示 name of the account, account number and current balance of each one
    2. 【已完成】a link that navigates the user to the account details*

    1. 【未完成】我不知道算不算是有个弹出的 确然删除,controller 本身就有个自动生成的comfirm,我还需要做吗??











    Delete
    Hint: implement this as a form with just a submit button. Create two controller actions:
    one action for GET requests, which asks the user to confirm by pressing a button. Create a
    second one adorned with the [HttpPost] attribute that processes the form and performs the
    “deletion” and informs the user that is has been deleted (or error, if there was an error).

























    route.config

                routes.MapRoute(
                    name: "Index",
                    url: "Bank/Account/List",
                    defaults: new { controller = "BankAccounts", action = "Index", id = UrlParameter.Optional }
                );
    
                routes.MapRoute(
                    name: "Delete",
                    url: "Bank/Account/Delete",
                    defaults: new { controller = "BankAccounts", action = "Create", id = UrlParameter.Optional }
                );
    











    When deleting an account, you should not actually delete it from the database, but rather flag it to be hidden using a Boolean in the model for the account. Once an account is “deleted” (i.e., hidden), the system should behave as if the account was in fact deleted from the database. For example, it should never again be viewable or accessible in any way through the user interface, nor should any transactions for that account be viewable. An account must have a $0.00 balance prior to deletion.

    1. 【已完成】只是隐藏不删除
    2. 【已完成】弹出一个窗口,显示如果不是0,不可以删除

    1. 【未完成】隐藏了某个账户,在Transaction里也不应该看见了











    A create account screen with URL suffix /Bank/Account/Create.
    Starts a new checking account with a $0.00 balance. The user should be able to enter a descriptive name for the account (e.g. “Mary’s Main Checking Account”) and account number of the new checking account to be created.
    The account number must be exactly 7 digits and be unique among all other accounts at the bank. When finished, this should take the user back to the bank accounts listing above.

    1. 【已解决】/Bank/Account/Create
    2. 【已解决】用户可以直接命名
    3. 【已解决】但是默认起始余额是 $0
    4. 【已解决】account number 也需要做用户做初始化
    5. 【已解决】完成账户create,转回到 listing view

    1. 【待解决】 如果我在 route.config 里修改了 transaction的create,之后会怎么样???











    An account details screen (/Bank/Account/{id}/Transaction/List),
    which shows the account name, account number, current account balance,
    and a listing of the 10 most recent transactions for the account specified in the URL. Each transaction should show the date, description, and amount of the transaction as well as a balance. There should be a “Create Transaction” button that takes the user to the new transaction screen, discussed below. An example of the transaction list is shown below in Table 1. You may show the comma in the numeric formatting, but this is not a requirement.

    1. 【已完成】Account Detail的界面包括了account name, account number, current account balance
    2. 【已完成】包括了最近10次的交易,用的是linq,不要在View里改,只显示当前的Account
    3. 【已完成】每笔交易要显示日期,描述,交易金额,余额
    4. 【已完成】需要有 “Create Transaction”
    5. 【已完成】may show the comma in the numeric formatting
    6. 【已完成】 (/Bank/Account/{id}/Transaction/List)
            public ActionResult AccountDetail(int id)
            {
                var transactions = db.Transactions.Include(t => t.BankAccount);
    
                var currenttransactions = (from u in transactions
                                          where u.BankAccountID == id
                                           orderby u.TransactionDate descending
                                           select u).Take(10);
                return View(currenttransactions.ToList());
            }
    











    However, all decimals must be displayed to 2 decimal places.
    See String.Format for ideas. Note that negative amounts are typically shown by enclosing the amount in parentheses.
    Clicking on a transaction should take you to the transaction details screen,
    discussed below.

    1.【已解决】都要是2位小数,负号用括号表示
    2.【已解决】 最后我也没有用String.Format , 而是在public double TransactionBalance { get; set; }前面使用了[DisplayFormat(DataFormatString = "{0:$#,##0.00;($#,##0.00)}", ApplyFormatInEditMode = true)] 的注解











    A new transaction screen (/Bank/Account/{id}/Transaction/Create), in which the user can create a new transaction for the account specified in the URL. Each transaction shall consist of at least: a globally unique primary key serving as a transaction number (database generated and not visible on this screen), the date and time of the transaction (need not be shown on the screen), a textual description of the transaction, and the amount of the transaction expressed as a positive decimal. A separate drop down list on the screen which is statically populated with the options “Check” or “Deposit” will indicate the type of transaction.
    Although this is how it should appear on the screen, you may represent check or deposit transactions however you wish in the model.

    1. 【已解决】 (/Bank/Account/{id}/Transaction/Create)
    2. 【已解决】DropDownList,可以保存 bool
    3. 【已解决】保存之后
    4. 【已解决】新的交易屏幕 (/Bank/Account/{id}/Transaction/Create)
    5. 【已完成】【自动完成】每笔交易至少应包括:作为transaction number--- unique primary key(数据库已生成并且在此屏幕上不可见)
    6. 【已完成】交易的日期和时间(不需要在屏幕上显示)
    7. 【已完成】 文本描述交易以及交易金额表示为正数小数。
    8. 在屏幕上单独的drop down list 中静态填充选项“Check” or “Deposit”将显示交易类型。
    9. 【已解决】用户可以在该屏幕中为URL中指定的账户创建新的交易。
    10. 【已解决】关于balance的加减法!deposit 要加!

    1. 【未解决】Transaction Index 显示type还是 勾
    1. Although this is how it should appear on the screen, you may represent check or deposit transactions however you wish in the model. 这句话没有读懂











    There should exist a Submit and Cancel button at the bottom of the screen. Transactions cannot be deleted once created, though they should be completely hidden from view if the parent account is deleted.
    Upon pressing the Submit button, the following validation should occur: all visible fields should be required.
    The transaction cannot be for $0.00, less than -$5,000.00 or more than $5,000.00.
    Transactions that would bring the account balance below $0.00 are not permitted.
    If valid, the transaction should be recorded and the user taken to the account transactions screen, described below. If the user presses the Cancel button, they should be directed to the account details screen described above.

    1. 【已完成】该交易不能为$ 0.00,小于 - $ 5,000.00或超过$ 5,000.00
    2. 【已完成】屏幕底部应该有一个提交和取消按钮。
    3. 【已完成】不允许将账户余额低于0.00美元的交易
    4. 【已完成】如下所述。如果用户按下“取消”按钮,则应将其指向上述帐户 account details screen

    1. 【未完成】交易无法在创建后删除,但如果父账户被删除,它们应该完全隐藏。

    2. 【未完成】按提交按钮后,应该发生以下验证:all visible fields should be required

    3. 【已完成】如果有效,应记录交易并将用户带到 account transactions screen











    A transaction details screen (/Bank/Account/{id1}/Transaction/{id2}) where {id1} is a the account number and {id2} is the transaction number. You should validate that the transaction corresponds to the account in question. The transaction details screen should provide a “read only” 3 view of the transaction: date and time of the transaction (month, day, and year, hour and minute), description of the transaction, and the amount of the transaction expressed as a decimal (positive for deposit, negative for check). A button should take the user back to the account details screen. Users should under no circumstance be allowed to view accounts that are not theirs or transactions for accounts that are not theirs. Other requirements are as follows:

    1. 【未解决】

    相关文章

      网友评论

          本文标题:2018-04-10 开胃学习.Net 系列 - MVC作业2

          本文链接:https://www.haomeiwen.com/subject/gqhghftx.html