public IActionResult GetInvoice([FromBody] JobLabourer input) { List <ResultVM> results = new List <ResultVM>(); var jobLabourers = _context.JobLabourer.Where(jb => jb.StartDay == input.StartDay && jb.EndDay == input.EndDay && jb.JobId == input.JobId) .Select(l => new JobLabourer { SkillId = l.SkillId, LabourerId = l.LabourerId, Labourer = l.Labourer, Skill = l.Skill, JobId = l.JobId, StartDay = l.StartDay, EndDay = l.EndDay }).ToList(); foreach (JobLabourer jb in jobLabourers) { var rate = _context.Skill.FirstOrDefault(s => s.SkillId == jb.SkillId).AdminReceives; var i = _context.LabourerAttendance.Where(la => la.LabourerId == jb.Labourer.LabourerId && la.JobId == jb.JobId && la.Date.CompareTo(jb.StartDay) >= 0 && la.Date.CompareTo(jb.EndDay) <= 0 && la.DailyQualityRating > 0).Count(); results.Add(new ResultVM { WorkedDays = i, TotalHours = i * 8, TotalAmount = rate * 8 * i, Labourer = jb.Labourer, Skill = jb.Skill }); } return(new ObjectResult(results)); }
public IActionResult PutSafetyMeetingCompeleted([FromBody] JobLabourer jobLabourer) { var joblabourers = _context.JobLabourer.Where(jl => jl.JobId == jobLabourer.JobId && jl.LabourerId == jobLabourer.LabourerId).ToList(); foreach (JobLabourer jl in joblabourers) { jl.SafetyMeetingCompleted = jobLabourer.SafetyMeetingCompleted; } ; _context.SaveChanges(); return(new ObjectResult(jobLabourer)); }
public IActionResult GetLabourerSafetyRating([FromBody] JobLabourer jlr) { var jobLabourer = _context.JobLabourer.SingleOrDefault(jl => jl.LabourerId == jlr.LabourerId && jl.JobId == jlr.JobId); if (jobLabourer != null) { return(new ObjectResult(jobLabourer.LabourerSafetyRating)); } else { return(NotFound()); } }
public IActionResult PutLabourerSafetyRating([FromBody] JobLabourer jlr) { var jobLabourer = _context.JobLabourer.SingleOrDefault(jl => jl.LabourerId == jlr.LabourerId && jl.JobId == jlr.JobId); if (jobLabourer != null) { jobLabourer.LabourerSafetyRating = jlr.LabourerSafetyRating; } else { return(NotFound()); } try { _context.SaveChanges(); } catch (DbUpdateException) { throw; } return(new ObjectResult(jobLabourer)); }