public async Task <IActionResult> Index() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var WorkstationLink = _context.Workstations.Any(w => w.CurrentUser.Id == userId); if (WorkstationLink == false) { return(RedirectToAction(nameof(Login))); } else { WorkstationKioskViewModel workstationKioskViewModel = new WorkstationKioskViewModel() { ApplicationUser = _applicationUserRepository.GetApplicationUser(User.FindFirstValue(ClaimTypes.NameIdentifier)), Department = _context.Workstations.Where(w => w.CurrentUser.Id == userId).Select(w => w.Department).FirstOrDefault(), Workstation = _context.Workstations.Where(w => w.CurrentUser.Id == userId).Include(w => w.CurrentUnit).Include(w => w.CurrentUnit.UnitType).FirstOrDefault(), UnitLog = _context.UnitLogs.Include(u => u.Workstation).Where(w => w.Unit == _context.Workstations.Where(w => w.CurrentUser.Id == userId).FirstOrDefault().CurrentUnit).OrderBy(u => u.EventDate).ToList() }; if (workstationKioskViewModel.UnitLog.Count == 0 && workstationKioskViewModel.Workstation.CurrentUnit != null) { await CreateLog(workstationKioskViewModel, "CHECKIN"); workstationKioskViewModel.UnitLog = _context.UnitLogs.Where(w => w.Unit == _context.Workstations.Where(w => w.CurrentUser.Id == userId).FirstOrDefault().CurrentUnit).ToList(); } return(View(workstationKioskViewModel)); } }
public async Task <IActionResult> RemoveHold(WorkstationKioskViewModel model) { var userTry = _context.Users.Where(u => u.Email == model.ApplicationUser.Email).FirstOrDefault(); if (userTry.UserRole == "QA" && userTry != null) { var entity = _context.Workstations .Include(w => w.CurrentUser) .Include(w => w.CurrentUnit) .FirstOrDefaultAsync(w => w.ID == model.Workstation.ID).Result; DateTime holdStart = _context.UnitLogs.Where(u => u.Unit == entity.CurrentUnit).OrderByDescending(u => u.EventDate).First(u => u.Event == "QA HOLD").EventDate; double nonValueAdd = TimeDifference(holdStart); var newLog = new UnitLog { ApplicationUser = entity.CurrentUser, Unit = entity.CurrentUnit, Workstation = entity, EventDate = DateTime.Now, NonValueAddedTime = nonValueAdd, Event = "GREEN TAG" }; await _context.AddAsync(newLog); entity.CurrentUnit.QA = false; _context.SaveChanges(); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public IViewComponentResult Invoke(WorkstationKioskViewModel model) { string view = "Default"; if (model.Workstation.CurrentUnit == null) { view = "Standby"; } return(View(view, model)); }
public IViewComponentResult Invoke(WorkstationKioskViewModel model) { if (model.Workstation.CurrentUnit == null) { return(View("Standby")); } if (model.Workstation.CurrentUnit.QA == true) { return(View("Hold")); } return(View("WIP")); }
public async Task <IActionResult> CreateLog(WorkstationKioskViewModel model, string logEvent) { UnitLog unitLog = new UnitLog { ApplicationUser = model.ApplicationUser, Unit = model.Workstation.CurrentUnit, Workstation = model.Workstation, EventDate = DateTime.Now, Event = logEvent }; await _context.AddAsync(unitLog); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }