Skip to content

Commit

Permalink
WIP site order
Browse files Browse the repository at this point in the history
  • Loading branch information
darakeon committed Sep 20, 2024
1 parent b0a87bd commit b34e607
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
30 changes: 26 additions & 4 deletions site/MVC/Models/OrdersCreateModel.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using DFM.BusinessLogic.Exceptions;
using DFM.BusinessLogic.Response;

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<AccountListItem, Boolean> AccountList { get; set; }
public IDictionary<CategoryListItem, Boolean> CategoryList { get; set; }

public List<String> SaveOrder()
{
Expand Down
31 changes: 21 additions & 10 deletions site/MVC/Views/Orders/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@
ViewBag.FormErrorsClass = hl["Errors"];
}

<div class="form-group col-lg-6 col-sm-6">
@Html.LabelFor(m => m.Order.Start, Context.Translate("StartDate"), new { @class = "control-label" })
@Html.ValidationMessageFor(m => m.Order.Start)<br />
@Html.TextBoxFor(m => m.Order.Start, new { type = "date", @class = "form-control " + hl["Start"] })
</div>

<div class="form-group col-lg-6 col-sm-6">
@Html.LabelFor(m => m.Order.End, Context.Translate("EndDate"), new { @class = "control-label" })
@Html.ValidationMessageFor(m => m.Order.End)<br />
@Html.TextBoxFor(m => m.Order.End, new { type = "date", @class = "form-control " + hl["End"] })
<div class="row">
<div class="form-group col-lg-6 col-sm-12">
@Html.LabelFor(m => m.Order.Start, Context.Translate("StartDate"), new { @class = "control-label" })
@Html.ValidationMessageFor(m => m.Order.Start)<br />
@Html.TextBoxFor(m => m.Order.Start, new { type = "date", @class = "form-control " + hl["Start"] })
</div>

<div class="form-group col-lg-6 col-sm-12">
@Html.LabelFor(m => m.Order.End, Context.Translate("EndDate"), new { @class = "control-label" })
@Html.ValidationMessageFor(m => m.Order.End)<br />
@Html.TextBoxFor(m => m.Order.End, new { type = "date", @class = "form-control " + hl["End"] })
</div>

<div class="form-group col-lg-12 col-sm-12">
@Html.ValidationMessageFor(m => m.Order.AccountList)<br />
@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" })
}
</div>
</div>

@section Footer {
Expand Down

0 comments on commit b34e607

Please sign in to comment.