Код: Выделить всё
// GET /User/TimeCardLog
public IActionResult TimeCardLog(int userId)
{
Console.WriteLine("The id is " + userId);
// Get the signed-in user's ID
var signedInUserId = User.GetSignedInUserId();
// Determine which user's timecards to retrieve
int targetUserId;
if (userId == signedInUserId)
{
targetUserId = signedInUserId;
}
else
{
targetUserId = userId;
}
var user = _svc.GetUser(targetUserId);
if (user is null)
{
Alert($"User {targetUserId} Not Found..", AlertType.warning);
return RedirectToAction(nameof(Index));//TimeCardLog
}
var timeCards = _tcSvc.GetTimeCardsByUser(targetUserId);
var model = new UserTimeCardsViewModel
{
User = user,
TimeCards = timeCards,
};
return View(model);
}
Код: Выделить всё
@model Shop
Employees in @Model.Name
[i][/i]
Name
Surname
Role
Edit Clock In-Out and Add Holiday Leave
Sickness
@if (Model.Users.Count == 0)
{
No Employees...
}
else
{
@foreach (var u in Model.Users)
{
var rowClass = "";
// Get today's timecard for the user
var todayTimeCard = u.TimeCards
.Where(tc => tc.ClockIn.Date == DateTime.Today)
.OrderByDescending(tc => tc.ClockIn)
.FirstOrDefault();
if (todayTimeCard != null)
{
rowClass = "table-success"; // Green row for users currently clocked in or a timecard for the current day
}
else
{
rowClass = "table-danger"; // Red row for users not currently clocked in or no timecard for that day
}
@u.Name
@u.LastName
@u.Role
@u.Id
[i]
Edit employee details
[/i]Remove employee
[i][/i]Re-assign employee to new shop
}
}
Я новичок в программировании, и это мой первый реальный опыт создания веб-сайта. . Это может быть простое решение, но я не могу этого понять. Любая помощь или идеи будут признательны!
Подробнее здесь: https://stackoverflow.com/questions/787 ... controller
Мобильная версия