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

  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. 【未解决】
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,098评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,213评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,960评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,519评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,512评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,533评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,914评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,574评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,804评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,563评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,644评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,350评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,933评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,908评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,146评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,847评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,361评论 2 342

推荐阅读更多精彩内容