これをコントローラーからビュー ( ) に渡そうとしています@ViewBag.Chapter7Total
:
ViewBag.Chapter7Total = calc.CalculatePrice(quoteData, Chapter7);
しかし、VSで「現在のコンテキストエラーに存在しません」というエラーが発生しています。
基本的に、2.Chapter7 または Chapter13 の間で使用する価格設定構造を決定する 2 番目のパラメーターを渡そうとしています。選択によって、計算を実行する 2 番目のパラメーターが決定されます。
ここに私の方法があります:
class Chapter
{
public decimal PaymentPlan { get; set; }
public decimal Price { get; set; }
}
public decimal decPaymentPlan(QuoteData quoteData, Chapter chapter)
{
if (quoteData.StepFilingInformation.PaymentPlanRadioButton
== StepFilingInformation.PaymentPlan.No)
return PriceQuote.priceNoPaymentPlan;
else
return chapter.PaymentPlan;
}
public decimal Calculate(QuoteData quoteData, Chapter chapter)
{
decimal total = chapter.Price;
total += this.decPaymentPlan(quoteData, chapter);
return total;
}
static Chapter Chapter7 = new Chapter() { Price = 799.00m, PaymentPlan = 100.00m };
最後に、これは私のコントローラーです:
public ActionResult EMailQuote()
{
Calculations calc = new Calculations();
Chapter chap = new Chapter();
QuoteData quoteData = new QuoteData
{
StepFilingInformation = new Models.StepFilingInformation
{
//just moking user input here temporarily to test out the UI
PaymentPlanRadioButton = Models.StepFilingInformation.PaymentPlan.Yes,
}
};
var total = calc.CalculatePrice(quoteData);
ViewBag.Chapter7Total = calc.CalculatePrice(quoteData, Chapter7);
return View(quoteData);
}
Chapter7に合格するために何をすればいいのかわからない。何かご意見は?
更新 1:
これは私のViewModel(QuoteData
)です:
public class QuoteData
{
public PriceQuote priceQuote;
public Calculations calculations;
public StepFilingInformation stepFilingInformation { get; set; }
public QuoteData()
{
PriceQuote = new PriceQuote();
Calculations = new Calculations();
}
}