@using Groceries.Data @using Humanizer @model ItemTagQuantity? @section head { @**@ }

Item Quantity (last 90 days)

@if (Model != null) { @if (Model.IsDivisible) { var quantity = Convert.ToDouble(Model.Quantity); var weekQuantity = Math.Round(quantity / 12); @(Model.IsMetric ? quantity.ToMetric() : quantity)@Model.Unit @Model.Tag (@(Model.IsMetric ? weekQuantity.ToMetric() : weekQuantity)@Model.Unit per week) } else { var name = Model.Unit != null ? $"{Model.Tag} {Model.Unit}" : Model.Tag; var avgQuantity = Model.Quantity / 12; var avgPeriod = "week"; if (avgQuantity < 1) { avgQuantity *= 4; avgPeriod = "month"; } @name.ToQuantity(Convert.ToInt32(Model.Quantity)) (@name.ToQuantity(Convert.ToInt32(avgQuantity)) per @avgPeriod) } }