2018-04-10 開(kāi)胃學(xué)習(xí).Net 系列 - MVC作業(yè)2

  1. 【待解決】 如果我在 route.config 里修改了 transaction的create,之后會(huì)怎么樣市殷?屈尼??

作業(yè)細(xì)節(jié)要求

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 褐着,其中設(shè)置的name就是在Html.ActionLink 會(huì)使用到的參數(shù)
            routes.MapRoute(
              name: "Index",
              url: "Bank/Account/List",
              defaults: new { controller = "BankAccounts", action = "Index", id = UrlParameter.Optional }
          );
  1. 【已完成】 /Bank/Account/Delete/{id} ,id應(yīng)該就是創(chuàng)建時(shí)候的 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. 【未完成】我不知道算不算是有個(gè)彈出的 確然刪除托呕,controller 本身就有個(gè)自動(dòng)生成的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. 【已完成】彈出一個(gè)窗口谴餐,顯示如果不是0,不可以刪除

  1. 【未完成】隱藏了某個(gè)賬戶(hù)呆抑,在Transaction里也不應(yīng)該看見(jiàn)了












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. 【已解決】用戶(hù)可以直接命名
  3. 【已解決】但是默認(rèn)起始余額是 $0
  4. 【已解決】account number 也需要做用戶(hù)做初始化
  5. 【已解決】完成賬戶(hù)create,轉(zhuǎn)回到 listing view

  1. 【待解決】 如果我在 route.config 里修改了 transaction的create汁展,之后會(huì)怎么樣鹊碍??食绿?












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里改器紧,只顯示當(dāng)前的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位小數(shù)熊尉,負(fù)號(hào)用括號(hào)表示
2.【已解決】 最后我也沒(méi)有用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. 【已完成】【自動(dòng)完成】每筆交易至少應(yīng)包括:作為transaction number--- unique primary key(數(shù)據(jù)庫(kù)已生成并且在此屏幕上不可見(jiàn))
  6. 【已完成】交易的日期和時(shí)間(不需要在屏幕上顯示)
  7. 【已完成】 文本描述交易以及交易金額表示為正數(shù)小數(shù)狰住。
  8. 在屏幕上單獨(dú)的drop down list 中靜態(tài)填充選項(xiàng)“Check” or “Deposit”將顯示交易類(lèi)型张吉。
  9. 【已解決】用戶(hù)可以在該屏幕中為URL中指定的賬戶(hù)創(chuàng)建新的交易。
  10. 【已解決】關(guān)于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. 這句話沒(méi)有讀懂












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或超過(guò)$ 5,000.00
  2. 【已完成】屏幕底部應(yīng)該有一個(gè)提交和取消按鈕创南。
  3. 【已完成】不允許將賬戶(hù)余額低于0.00美元的交易
  4. 【已完成】如下所述伦忠。如果用戶(hù)按下“取消”按鈕,則應(yīng)將其指向上述帳戶(hù) account details screen

  1. 【未完成】交易無(wú)法在創(chuàng)建后刪除稿辙,但如果父賬戶(hù)被刪除昆码,它們應(yīng)該完全隱藏。

  2. 【未完成】按提交按鈕后邓深,應(yīng)該發(fā)生以下驗(yàn)證:all visible fields should be required

  3. 【已完成】如果有效未桥,應(yīng)記錄交易并將用戶(hù)帶到 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. 【未解決】
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市芥备,隨后出現(xiàn)的幾起案子冬耿,更是在濱河造成了極大的恐慌,老刑警劉巖萌壳,帶你破解...
    沈念sama閱讀 212,080評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件亦镶,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡袱瓮,警方通過(guò)查閱死者的電腦和手機(jī)缤骨,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,422評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)尺借,“玉大人绊起,你說(shuō)我怎么就攤上這事×钦叮” “怎么了虱歪?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,630評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)栅表。 經(jīng)常有香客問(wèn)我笋鄙,道長(zhǎng),這世上最難降的妖魔是什么怪瓶? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,554評(píng)論 1 284
  • 正文 為了忘掉前任萧落,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘找岖。我一直安慰自己陨倡,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,662評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布宣增。 她就那樣靜靜地躺著玫膀,像睡著了一般。 火紅的嫁衣襯著肌膚如雪爹脾。 梳的紋絲不亂的頭發(fā)上帖旨,一...
    開(kāi)封第一講書(shū)人閱讀 49,856評(píng)論 1 290
  • 那天,我揣著相機(jī)與錄音灵妨,去河邊找鬼解阅。 笑死,一個(gè)胖子當(dāng)著我的面吹牛泌霍,可吹牛的內(nèi)容都是我干的货抄。 我是一名探鬼主播,決...
    沈念sama閱讀 39,014評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼朱转,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼蟹地!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起藤为,我...
    開(kāi)封第一講書(shū)人閱讀 37,752評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤怪与,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后缅疟,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體分别,經(jīng)...
    沈念sama閱讀 44,212評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,541評(píng)論 2 327
  • 正文 我和宋清朗相戀三年存淫,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了耘斩。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,687評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡桅咆,死狀恐怖括授,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情岩饼,我是刑警寧澤刽脖,帶...
    沈念sama閱讀 34,347評(píng)論 4 331
  • 正文 年R本政府宣布,位于F島的核電站忌愚,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏却邓。R本人自食惡果不足惜硕糊,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,973評(píng)論 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧简十,春花似錦檬某、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,777評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至胰默,卻和暖如春场斑,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背牵署。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,006評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工漏隐, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人奴迅。 一個(gè)月前我還...
    沈念sama閱讀 46,406評(píng)論 2 360
  • 正文 我出身青樓青责,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親取具。 傳聞我的和親對(duì)象是個(gè)殘疾皇子脖隶,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,576評(píng)論 2 349

推薦閱讀更多精彩內(nèi)容