Checking tenantId in MVC to only display customisations if tenantId equals 1
This commit is contained in:
parent
0365b52e66
commit
48e795fda2
@ -81,8 +81,11 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
public async Task<IActionResult> Detail(string orderId)
|
||||
{
|
||||
var user = _appUserParser.Parse(HttpContext.User);
|
||||
if (user.TenantId == 1)
|
||||
{
|
||||
Boolean RFIDScanned = await AllGoodsRFIDScanned(orderId);
|
||||
ViewData["RFIDScanned"] = RFIDScanned;
|
||||
}
|
||||
|
||||
var order = await _orderSvc.GetOrder(user, orderId);
|
||||
return View(order);
|
||||
@ -91,11 +94,17 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
public async Task<IActionResult> Index(Order item)
|
||||
{
|
||||
var user = _appUserParser.Parse(HttpContext.User);
|
||||
|
||||
|
||||
var vm = await _orderSvc.GetMyOrders(user);
|
||||
|
||||
if (user.TenantId == 1)
|
||||
{
|
||||
List<ShippingInformation> shippingInformation = GetShippingInfo(vm);
|
||||
_logger.LogInformation("----- Shipping info{@ShippingInformation}", shippingInformation);
|
||||
|
||||
ViewData["ShippingInfo"] = shippingInformation;
|
||||
}
|
||||
|
||||
return View(vm);
|
||||
}
|
||||
|
||||
@ -148,7 +157,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
_logger.LogInformation("----- Exception{@e} -----", e);
|
||||
}
|
||||
}
|
||||
|
@ -28,5 +28,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public string LastName { get; set; }
|
||||
[Required]
|
||||
public int TenantId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,10 @@
|
||||
<section class="esh-orders_detail-title col-2">Date</section>
|
||||
<section class="esh-orders_detail-title col-2">Total</section>
|
||||
<section class="esh-orders_detail-title col-2">Status</section>
|
||||
@if (rfidScanned != null)
|
||||
{
|
||||
<section class="esh-orders_detail-title col-2">RFID Scanned</section>
|
||||
}
|
||||
</article>
|
||||
|
||||
<article class="esh-orders_detail-items row">
|
||||
@ -29,7 +32,10 @@
|
||||
<section class="esh-orders_detail-item col-2">@Model.OrderNumber</section>
|
||||
<section class="esh-orders_detail-item col-2">@Model.Date</section>
|
||||
<section class="esh-orders_detail-title col-2">@Model.Status</section>
|
||||
@if (rfidScanned != null)
|
||||
{
|
||||
<section class="esh-orders_detail-title col-2">@rfidScanned</section>
|
||||
}
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
@ -5,16 +5,17 @@
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "My Orders";
|
||||
var headerList = new List<Header>() {
|
||||
new Header() { Controller = "Catalog", Text = "Back to catalog" },
|
||||
new Header() { Text = " / " },
|
||||
new Header() { Controller = "OrderManagement", Text = "Orders Management" } };
|
||||
var headerList = new List<Header>()
|
||||
{
|
||||
new Header() {Controller = "Catalog", Text = "Back to catalog"},
|
||||
new Header() {Text = " / "},
|
||||
new Header() {Controller = "OrderManagement", Text = "Orders Management"}
|
||||
};
|
||||
var shippingInfo = ViewData["ShippingInfo"] as List<ShippingInformation>;
|
||||
|
||||
}
|
||||
|
||||
<div class="esh-orders">
|
||||
<partial name="_Header" model="headerList" />
|
||||
<partial name="_Header" model="headerList"/>
|
||||
|
||||
<div class="container">
|
||||
<article class="esh-orders-titles row">
|
||||
@ -22,8 +23,11 @@
|
||||
<section class="esh-orders-title col-2">Date</section>
|
||||
<section class="esh-orders-title col-1">Total</section>
|
||||
<section class="esh-orders-title col-1">Status</section>
|
||||
@if (shippingInfo != null)
|
||||
{
|
||||
<section class="esh-orders-title col-2">Shipping date</section>
|
||||
<section class="esh-orders-title col-2">Estimated arrival date</section>
|
||||
}
|
||||
<section class="esh-orders-title col-2"></section>
|
||||
|
||||
</article>
|
||||
@ -36,13 +40,16 @@
|
||||
<section class="esh-orders-item col-2">@item.Date.ToShortDateString()</section>
|
||||
<section class="esh-orders-item col-1">$ @Html.DisplayFor(modelItem => item.Total)</section>
|
||||
<section class="esh-orders-item col-1">@Html.DisplayFor(modelItem => item.Status)</section>
|
||||
@if (shippingInfo != null)
|
||||
{
|
||||
<section class="esh-orders-item col-2">
|
||||
@for (var i = 0; i < shippingInfo.Count(); i++)
|
||||
{
|
||||
var si = shippingInfo[i];
|
||||
if (si.OrderNumber.Equals(item.OrderNumber))
|
||||
{
|
||||
@si.ShippingTime.ToShortDateString();
|
||||
@si.ShippingTime.ToShortDateString()
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -53,11 +60,13 @@
|
||||
var si = shippingInfo[i];
|
||||
if (si.OrderNumber.Equals(item.OrderNumber))
|
||||
{
|
||||
@si.ArrivalTime.ToShortDateString();
|
||||
@si.ArrivalTime.ToShortDateString()
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
</section>
|
||||
}
|
||||
<section class="esh-orders-item col-1">
|
||||
<a class="esh-orders-link" asp-controller="Order" asp-action="Detail" asp-route-orderId="@item.OrderNumber">Detail</a>
|
||||
</section>
|
||||
@ -72,7 +81,3 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user