private async Task onLoad(int?id, int?Did) { Department = await _context.Department.ToListAsync(); Employee = await _context.Employee .Include(e => e.Company) .Include(e => e.Department) .Include(e => e.EmployeeType) .Include(e => e.Location) .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id); OT = await _context.OT.FirstOrDefaultAsync(m => m.OTID == Did); DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).ToListAsync(); DetailOT = DetailOT.Where(d => d.OT_OTID == Did && d.Status.Equals("Allow")).ToList(); Part = await _context.Part.ToListAsync(); FoodSet = await _context.FoodSet.ToListAsync(); CarType = await _context.CarType.ToListAsync(); CarType = CarType.OrderByDescending(o => o.Seat).ToList(); }
public async Task <IActionResult> OnPostAddAllAsync(int id, int Did) { await OnLoad(id); List <DetailOT> newDetailOTs = DetailOT.Where(n => n.OT_OTID == Did).ToList(); foreach (var item in newDetailOTs) { DetailOT newDetailOT = item; newDetailOT.Status = "Allow"; _context.Attach(newDetailOT).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetailOTExists(newDetailOT.DetailOTID)) { return(NotFound()); } else { throw; } } } return(RedirectToPage("./../listOTs/listEmpOT", new { id = Employee.EmployeeID })); }
public async Task <ActionResult <DetailOT> > PostDetailOT(DetailOT detailOT) { _context.DetailOT.Add(detailOT); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDetailOT", new { id = detailOT.DetailOTID }, detailOT)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Employee = await _context.Employee .Include(e => e.Company) .Include(e => e.Department) .Include(e => e.EmployeeType) .Include(e => e.Location) .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id); if (Employee == null) { return(NotFound()); } ViewData["Company_CompanyID"] = new SelectList(_context.Company, "CompanyID", "CompanyID"); ViewData["Department_DepartmentID"] = new SelectList(_context.Department, "DepartmentID", "DepartmentID"); ViewData["EmployeeType_EmployeeTypeID"] = new SelectList(_context.EmployeeType, "EmployeeTypeID", "EmployeeTypeID"); ViewData["Location_LocationID"] = new SelectList(_context.Location, "LocationID", "LocationID"); ViewData["Position_PositionID"] = new SelectList(_context.Position, "PositionID", "PositionID"); DetailOT = await _context.DetailOT .Include(d => d.CarType) .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).ToListAsync(); DetailOT = DetailOT.Where(e => e.Employee_EmpID == id).ToList(); return(Page()); }
public async Task <IActionResult> PutDetailOT(int id, DetailOT detailOT) { if (id != detailOT.DetailOTID) { return(BadRequest()); } _context.Entry(detailOT).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetailOTExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DetailOT = await _context.DetailOT .Include(d => d.CarType) .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).FirstOrDefaultAsync(m => m.DetailOTID == id); if (DetailOT == null) { return(NotFound()); } ViewData["CarType_CarTypeID"] = new SelectList(_context.CarType, "CarTypeID", "CarTypeID"); ViewData["Employee_EmpID"] = new SelectList(_context.Employee, "EmployeeID", "EmployeeID"); ViewData["FoodSet_FoodSetID"] = new SelectList(_context.FoodSet, "FoodSetID", "FoodSetID"); ViewData["OT_OTID"] = new SelectList(_context.OT, "OTID", "OTID"); ViewData["Part_PaetID"] = new SelectList(_context.Part, "PartID", "PartID"); return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id, int?Did) { if (id == null) { return(NotFound()); } Employee = await _context.Employee .Include(e => e.Department) .Include(e => e.EmployeeType) .Include(e => e.Location) .Include(e => e.Position).FirstOrDefaultAsync(e => e.EmployeeID == id); DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).Where(d => d.OT_OTID == Did).ToListAsync(); DetailOT = DetailOT.Where(d => d.Employee.Employee_DepartmentID == Employee.Employee_DepartmentID).ToList(); if (DetailOT == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { Employee = HttpContext.Session.GetLogin(_context.Employee); if (id == null) { return(NotFound()); } DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.EmployeeAdd) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Point).FirstOrDefaultAsync(m => m.DetailOTID == id); if (DetailOT == null) { return(NotFound()); } ViewData["Employee_EmpID"] = new SelectList(_context.Employee, "EmployeeID", "EmployeeID"); ViewData["Employee_UserAdd_EmpID"] = new SelectList(_context.Employee, "EmployeeID", "EmployeeID"); ViewData["FoodSet_FoodSetID"] = new SelectList(_context.FoodSet, "FoodSetID", "FoodSetID"); ViewData["OT_OTID"] = new SelectList(_context.OT, "OTID", "OTID"); ViewData["Point_PointID"] = new SelectList(_context.Point, "PointID", "PointID"); return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } DetailOT = await _context.DetailOT.FindAsync(id); if (DetailOT != null) { _context.DetailOT.Remove(DetailOT); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task<IActionResult> OnGetAsync(int? Did) { try { await onLoad(Did); } catch (Exception) { return RedirectToPage("./index"); } if (OT == null) { return NotFound(); } if (Employee == null) { return NotFound(); } OTs = ListOTDetail(Did); Depasments = OTDetailOTList(); IList<DetailOT> mDetailOTnew; if (OT.TypeOT.Equals("Saturday") || OT.TypeOT.Equals("Sunday")) { mDetailOTnew = DetailOT.Where(d => (d.Type.Equals("Go") || d.Type.Equals("Go and Back"))&& d.TimeStart.Hour==8 && d.TimeStart.Minute == 0).ToList(); Round_8 = ManageCar(mDetailOTnew); mDetailOTnew = DetailOT.Where(d => (d.Type.Equals("Back") || d.Type.Equals("Go and Back")) && d.TimeEnd.Hour == 17 && d.TimeEnd.Minute == 0).ToList(); Round_17 = ManageCar(mDetailOTnew); mDetailOTnew = DetailOT.Where(d => (d.Type.Equals("Back") || d.Type.Equals("Go and Back")) && d.TimeEnd.Hour == 20 && d.TimeEnd.Minute == 0).ToList(); Round_20 = ManageCar(mDetailOTnew); } else { mDetailOTnew = DetailOT.Where(d => d.Type.Equals("Back") && d.TimeEnd.Hour == 20 && d.TimeEnd.Minute == 0).ToList(); Round_20 = ManageCar(mDetailOTnew); } return Page(); }
public async Task <IActionResult> OnPostRemoveAsync(int id, int Did) { DetailOTs = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).FirstOrDefaultAsync(e => e.DetailOTID == Did); DetailOTs.Status = "Disallow"; _context.Attach(DetailOTs).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetailOTExists(DetailOTs.DetailOTID)) { return(NotFound()); } else { throw; } } Employee = await _context.Employee .Include(e => e.Department) .Include(e => e.EmployeeType) .Include(e => e.Location) .Include(e => e.Position).FirstOrDefaultAsync(e => e.EmployeeID == id); DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).Where(d => d.OT_OTID == DetailOTs.OT_OTID).ToListAsync(); DetailOT = DetailOT.Where(d => d.Employee.Employee_DepartmentID == Employee.Employee_DepartmentID).ToList(); return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DetailOT = await _context.DetailOT .Include(d => d.CarType) .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).FirstOrDefaultAsync(m => m.DetailOTID == id); if (DetailOT == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAddDisallowAsync(int id) { try { await OnLoad(id); } catch (Exception) { return(RedirectToPage("./index")); } var newDetailOTs = await _context.DetailOT.Include(d => d.Employee).Where(n => n.OT_OTID == id && n.Employee.Department_DepartmentID == Employee.Department_DepartmentID && n.Status.Equals("Pending for approval")).ToArrayAsync(); foreach (var item in newDetailOTs) { DetailOT newDetailOT = item; newDetailOT.Status = "Disallow"; _context.Attach(newDetailOT).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetailOTExists(newDetailOT.DetailOTID)) { return(NotFound()); } else { throw; } } } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { Employee = HttpContext.Session.GetLogin(_context.Employee); if (id == null) { return(NotFound()); } DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.EmployeeAdd) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Point).FirstOrDefaultAsync(m => m.DetailOTID == id); if (DetailOT == null) { return(NotFound()); } return(Page()); }
private async Task OnLoad(int?id) { Employee = await _context.Employee .Include(e => e.Company) .Include(e => e.Department) .Include(e => e.EmployeeType) .Include(e => e.Location) .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id); DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).ToListAsync(); DetailOT = DetailOT.Where(d => d.Employee.Employee_DepartmentID == Employee.Employee_DepartmentID).ToList(); DetailOT = DetailOT.Where(d => d.Status.Equals("Pending for approval")).ToList(); OT = await _context.OT.ToListAsync(); OT = OT.Where(o => o.TypStatus.Equals("Manage Car")).ToList(); }
private OTs ListOTDetail(int?Did) { OTs OTsnew = new OTs(); DetailOTnew = DetailOT.Where(d => d.OT_OTID == Did && d.Status.Equals("Allow")).ToList(); OTsnew.countEmp = DetailOTnew.Count; foreach (var i in DetailOTnew) { if (i.FoodSet.NameSet.Equals("No")) { OTsnew.countFood = OTsnew.countFood + 1; } if (!i.Type.Equals("No")) { OTsnew.countCar = OTsnew.countCar + 1; } } return(OTsnew); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DetailOT = await _context.DetailOT .Include(d => d.Employee) .Include(d => d.FoodSet) .Include(d => d.OT) .Include(d => d.Part).ToListAsync(); DetailOT = DetailOT.Where(d => d.Employee_EmpID.Equals(id)).ToList(); DetailOT = DetailOT.Where(d => d.Status.Equals("Approved")).ToList(); countHourOT = new TimeSpan(); foreach (var item in DetailOT) { countHourOT = countHourOT + item.Hour; } Employee = await _context.Employee .Include(e => e.Company) .Include(e => e.Department) .Include(e => e.EmployeeType) .Include(e => e.Location) .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id); if (Employee == null) { return(NotFound()); } return(Page()); }
private OTs ListOTDetail(int?Did) { OTs OTsnew = new OTs(); DetailOTnew = DetailOT.Where(d => d.OT_OTID == Did && d.Status.Equals("Allow")).ToList(); OTsnew.countEmp = DetailOTnew.Count; OTsnew.countCar = DetailCarQueue.Count; OTsnew.countFood = DetailOTnew.Where(e => !e.FoodSet.NameSet.Equals("No")).ToList().Count; //foreach (var i in DetailOTnew) //{ // if (i.FoodSet.NameSet.Equals("No")) // { // OTsnew.countFood = OTsnew.countFood + 1; // } // if (!i.Type.Equals("No")) // { // OTsnew.countCar = OTsnew.countCar + 1; // } //} return(OTsnew); }