Browse Source

Checking tenantId in MVC to only display customisations if tenantId equals 1

pull/1240/head
espent1004 5 years ago
parent
commit
48e795fda2
4 changed files with 61 additions and 40 deletions
  1. +15
    -7
      src/Web/WebMVC/Controllers/OrderController.cs
  2. +2
    -0
      src/Web/WebMVC/ViewModels/ApplicationUser.cs
  3. +8
    -2
      src/Web/WebMVC/Views/Order/Detail.cshtml
  4. +36
    -31
      src/Web/WebMVC/Views/Order/Index.cshtml

+ 15
- 7
src/Web/WebMVC/Controllers/OrderController.cs View File

@ -81,8 +81,11 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
public async Task<IActionResult> Detail(string orderId) public async Task<IActionResult> Detail(string orderId)
{ {
var user = _appUserParser.Parse(HttpContext.User); var user = _appUserParser.Parse(HttpContext.User);
Boolean RFIDScanned = await AllGoodsRFIDScanned(orderId);
ViewData["RFIDScanned"] = RFIDScanned;
if (user.TenantId == 1)
{
Boolean RFIDScanned = await AllGoodsRFIDScanned(orderId);
ViewData["RFIDScanned"] = RFIDScanned;
}
var order = await _orderSvc.GetOrder(user, orderId); var order = await _orderSvc.GetOrder(user, orderId);
return View(order); return View(order);
@ -91,11 +94,17 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
public async Task<IActionResult> Index(Order item) public async Task<IActionResult> Index(Order item)
{ {
var user = _appUserParser.Parse(HttpContext.User); var user = _appUserParser.Parse(HttpContext.User);
var vm = await _orderSvc.GetMyOrders(user); var vm = await _orderSvc.GetMyOrders(user);
List<ShippingInformation> shippingInformation = GetShippingInfo(vm);
_logger.LogInformation("----- Shipping info{@ShippingInformation}", shippingInformation);
ViewData["ShippingInfo"] = shippingInformation;
if (user.TenantId == 1)
{
List<ShippingInformation> shippingInformation = GetShippingInfo(vm);
_logger.LogInformation("----- Shipping info{@ShippingInformation}", shippingInformation);
ViewData["ShippingInfo"] = shippingInformation;
}
return View(vm); return View(vm);
} }
@ -108,7 +117,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
query["orderId"] = orderId; query["orderId"] = orderId;
builder.Query = query.ToString(); builder.Query = query.ToString();
string url = builder.ToString(); string url = builder.ToString();
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
var response = await client.GetAsync( var response = await client.GetAsync(
@ -148,7 +157,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
_logger.LogInformation("----- Exception{@e} -----", e); _logger.LogInformation("----- Exception{@e} -----", e);
} }
} }


+ 2
- 0
src/Web/WebMVC/ViewModels/ApplicationUser.cs View File

@ -28,5 +28,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
public string Name { get; set; } public string Name { get; set; }
[Required] [Required]
public string LastName { get; set; } public string LastName { get; set; }
[Required]
public int TenantId { get; set; }
} }
} }

+ 8
- 2
src/Web/WebMVC/Views/Order/Detail.cshtml View File

@ -21,7 +21,10 @@
<section class="esh-orders_detail-title col-2">Date</section> <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">Total</section>
<section class="esh-orders_detail-title col-2">Status</section> <section class="esh-orders_detail-title col-2">Status</section>
<section class="esh-orders_detail-title col-2">RFID Scanned</section>
@if (rfidScanned != null)
{
<section class="esh-orders_detail-title col-2">RFID Scanned</section>
}
</article> </article>
<article class="esh-orders_detail-items row"> <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.OrderNumber</section>
<section class="esh-orders_detail-item col-2">@Model.Date</section> <section class="esh-orders_detail-item col-2">@Model.Date</section>
<section class="esh-orders_detail-title col-2">@Model.Status</section> <section class="esh-orders_detail-title col-2">@Model.Status</section>
<section class="esh-orders_detail-title col-2">@rfidScanned</section>
@if (rfidScanned != null)
{
<section class="esh-orders_detail-title col-2">@rfidScanned</section>
}
</article> </article>
</section> </section>


+ 36
- 31
src/Web/WebMVC/Views/Order/Index.cshtml View File

@ -5,16 +5,17 @@
@{ @{
ViewData["Title"] = "My Orders"; 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>; var shippingInfo = ViewData["ShippingInfo"] as List<ShippingInformation>;
} }
<div class="esh-orders"> <div class="esh-orders">
<partial name="_Header" model="headerList" />
<partial name="_Header" model="headerList"/>
<div class="container"> <div class="container">
<article class="esh-orders-titles row"> <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-2">Date</section>
<section class="esh-orders-title col-1">Total</section> <section class="esh-orders-title col-1">Total</section>
<section class="esh-orders-title col-1">Status</section> <section class="esh-orders-title col-1">Status</section>
<section class="esh-orders-title col-2">Shipping date</section>
<section class="esh-orders-title col-2">Estimated arrival date</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> <section class="esh-orders-title col-2"></section>
</article> </article>
@ -36,28 +40,33 @@
<section class="esh-orders-item col-2">@item.Date.ToShortDateString()</section> <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.Total)</section>
<section class="esh-orders-item col-1">@Html.DisplayFor(modelItem => item.Status)</section> <section class="esh-orders-item col-1">@Html.DisplayFor(modelItem => item.Status)</section>
<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))
@if (shippingInfo != null)
{
<section class="esh-orders-item col-2">
@for (var i = 0; i < shippingInfo.Count(); i++)
{ {
@si.ShippingTime.ToShortDateString();
break;
var si = shippingInfo[i];
if (si.OrderNumber.Equals(item.OrderNumber))
{
@si.ShippingTime.ToShortDateString()
;
break;
}
} }
}
</section>
<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))
</section>
<section class="esh-orders-item col-2">
@for (var i = 0; i < shippingInfo.Count(); i++)
{ {
@si.ArrivalTime.ToShortDateString();
break;
var si = shippingInfo[i];
if (si.OrderNumber.Equals(item.OrderNumber))
{
@si.ArrivalTime.ToShortDateString()
;
break;
}
} }
}
</section>
</section>
}
<section class="esh-orders-item col-1"> <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> <a class="esh-orders-link" asp-controller="Order" asp-action="Detail" asp-route-orderId="@item.OrderNumber">Detail</a>
</section> </section>
@ -71,8 +80,4 @@
} }
} }
</div> </div>
</div>
</div>

Loading…
Cancel
Save