Merge pull request #3 from biancacorsatea/master

Changed View Shifts
This commit is contained in:
Jim Paine 2020-04-14 15:14:38 +01:00 коммит произвёл GitHub
Родитель d94c1bce0b 9382ea4b10
Коммит be8fda65d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 58 добавлений и 26 удалений

Просмотреть файл

@ -100,15 +100,22 @@ namespace Project.Zap.Controllers
[Authorize(Policy = "OrgAManager")]
public IActionResult ViewShift(ShiftViewModel viewModel)
{
Shift shift = this.shiftRepository.Get(x => x.StoreName == viewModel.StoreName && x.Start == viewModel.Start && x.End == viewModel.End && x.WorkType == viewModel.WorkType).FirstOrDefault();
if (shift.EmployeeId != null)
IEnumerable<Shift> shifts = this.shiftRepository.Get(x => x.StoreName == viewModel.StoreName && x.Start == viewModel.Start && x.End == viewModel.End && x.WorkType == viewModel.WorkType).Where(x => x.EmployeeId != null);
List<Microsoft.Graph.User> list = new List<Microsoft.Graph.User>();
if (shifts.Count() == 0)
{
var employee = graphServiceClient.Users[shift.EmployeeId].Request().GetAsync().Result;
ViewData["Employee"] = employee.GivenName + " " + employee.Surname;
ViewData["NoEmployees"] = "No employees are booked for this shift.";
}
foreach (var shift in shifts)
{
list.Add(graphServiceClient.Users[shift.EmployeeId].Request().GetAsync().Result);
}
ViewData["Employees"] = list;
return View(viewModel);
}

Просмотреть файл

@ -61,7 +61,7 @@
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgAManager")).Succeeded)
{
<td><a asp-controller="Shift" asp-action="ViewShift" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")" asp-route-WorkType="@shift.WorkType">@Localizer["LinkView"]</a></td>
<td><a asp-controller="Shift" asp-action="ViewShift" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")" asp-route-WorkType="@shift.WorkType" asp-route-Quantity="@shift.Quantity" asp-route-Available="@shift.Available">@Localizer["LinkView"]</a></td>
<td><a asp-controller="Shift" asp-action="Delete" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")" asp-route-WorkType="@shift.WorkType">@Localizer["LinkDelete"]</a></td>
}

Просмотреть файл

@ -4,29 +4,54 @@
@inject IViewLocalizer Localizer
}
@{
var employees = ViewData["Employees"] as List<Microsoft.Graph.User>;
}
@model Project.Zap.Models.ShiftViewModel
<h1>@Localizer["Title"]</h1>
<table class="table">
<thead>
<tr>
<th>@Localizer["TableStoreName"]</th>
<th>@Localizer["TableStart"]</th>
<th>@Localizer["TableEnd"]</th>
<th>@Localizer["TableWorkType"]</th>
<th>@Localizer["TableEmployee"]</th>
</tr>
</thead>
<tbody>
<tr>
<td>@Model.StoreName</td>
<td>@Model.Start</td>
<td>@Model.End</td>
<td>@Model.WorkType</td>
<td>@ViewData["Employee"]</td>
</tr>
</tbody>
</table>
<dl class="row">
<dt class="col-sm-3">@Localizer["TableStoreName"]</dt>
<dd class="col-sm-9">@Model.StoreName</dd>
<dt class="col-sm-3">@Localizer["TableStart"]</dt>
<dd class="col-sm-9">@Model.Start</dd>
<dt class="col-sm-3">@Localizer["TableEnd"]</dt>
<dd class="col-sm-9">@Model.End</dd>
<dt class="col-sm-3 text-truncate">@Localizer["TableWorkType"]</dt>
<dd class="col-sm-9">@Model.WorkType</dd>
<dt class="col-sm-3">@Localizer["TableQuantity"]</dt>
<dd class="col-sm-9">@Model.Quantity</dd>
<dt class="col-sm-3">@Localizer["TableAvailable"]</dt>
<dd class="col-sm-9">@Model.Available</dd>
<dt class="col-sm-3">@Localizer["Employees"]</dt>
<dd>
<ul>
@if (ViewData.ContainsKey("NoEmployees"))
{
<li>@ViewData["NoEmployees"]</li>
}
else
{
@foreach (var employee in employees)
{
<li>@employee.GivenName @employee.Surname</li>
}
}
</ul>
</dd>
</dl>