From b34e60774c51184bd7bdd0063a30638eb140862a Mon Sep 17 00:00:00 2001 From: Dara Keon Date: Fri, 20 Sep 2024 02:59:35 +0100 Subject: [PATCH] WIP site order --- site/MVC/Models/OrdersCreateModel.cs | 30 +++++++++++++++++++++++---- site/MVC/Views/Orders/Create.cshtml | 31 +++++++++++++++++++--------- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/site/MVC/Models/OrdersCreateModel.cs b/site/MVC/Models/OrdersCreateModel.cs index 9d3872426..846e323f1 100644 --- a/site/MVC/Models/OrdersCreateModel.cs +++ b/site/MVC/Models/OrdersCreateModel.cs @@ -1,5 +1,7 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using DFM.BusinessLogic.Exceptions; using DFM.BusinessLogic.Response; @@ -7,11 +9,31 @@ namespace DFM.MVC.Models; public class OrdersCreateModel : BaseSiteModel { - public OrderInfo Order { get; set; } = new() + public OrdersCreateModel() { - Start = DateTime.Today, - End = DateTime.Today, - }; + Order = new() + { + Start = DateTime.Today, + End = DateTime.Today, + }; + + var accountList = admin.GetAccountList(true) + .Union(admin.GetAccountList(false)) + .ToList(); + + AccountList = accountList.ToDictionary(a => a, _ => false); + + var categoryList = admin.GetCategoryList(true) + .Union(admin.GetCategoryList(false)) + .ToList(); + + CategoryList = categoryList.ToDictionary(a => a, _ => false); + } + + public OrderInfo Order { get; set; } + + public IDictionary AccountList { get; set; } + public IDictionary CategoryList { get; set; } public List SaveOrder() { diff --git a/site/MVC/Views/Orders/Create.cshtml b/site/MVC/Views/Orders/Create.cshtml index 67a2448ec..dc397c802 100644 --- a/site/MVC/Views/Orders/Create.cshtml +++ b/site/MVC/Views/Orders/Create.cshtml @@ -24,16 +24,27 @@ ViewBag.FormErrorsClass = hl["Errors"]; } -
- @Html.LabelFor(m => m.Order.Start, Context.Translate("StartDate"), new { @class = "control-label" }) - @Html.ValidationMessageFor(m => m.Order.Start)
- @Html.TextBoxFor(m => m.Order.Start, new { type = "date", @class = "form-control " + hl["Start"] }) -
- -
- @Html.LabelFor(m => m.Order.End, Context.Translate("EndDate"), new { @class = "control-label" }) - @Html.ValidationMessageFor(m => m.Order.End)
- @Html.TextBoxFor(m => m.Order.End, new { type = "date", @class = "form-control " + hl["End"] }) +
+
+ @Html.LabelFor(m => m.Order.Start, Context.Translate("StartDate"), new { @class = "control-label" }) + @Html.ValidationMessageFor(m => m.Order.Start)
+ @Html.TextBoxFor(m => m.Order.Start, new { type = "date", @class = "form-control " + hl["Start"] }) +
+ +
+ @Html.LabelFor(m => m.Order.End, Context.Translate("EndDate"), new { @class = "control-label" }) + @Html.ValidationMessageFor(m => m.Order.End)
+ @Html.TextBoxFor(m => m.Order.End, new { type = "date", @class = "form-control " + hl["End"] }) +
+ +
+ @Html.ValidationMessageFor(m => m.Order.AccountList)
+ @foreach (var key in Model.AccountList.Keys) + { + @Html.CheckBoxFor(m => m.AccountList[key]) + @Html.LabelFor(m => m.AccountList[key], key.Name, new { @class = "control-label" }) + } +
@section Footer {