public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var labour = await _dataContext.Labours .Include(p => p.Employee) .Include(p => p.LabourType) .FirstOrDefaultAsync(p => p.Id == id.Value); if (labour == null) { return(NotFound()); } var model = new LabourViewModel { Start = labour.Start, Id = labour.Id, ImageUrl = labour.ImageUrl, Name = labour.Name, EmployeeId = labour.Employee.Id, LabourTypeId = labour.LabourType.Id, LabourTypes = _combosHelper.GetComboLabourTypes(), Activity = labour.Activity, Remarks = labour.Remarks }; return(View(model)); }
public async Task <IActionResult> AddLabour(int?id) { if (id == null) { return(NotFound()); } var employee = await _dataContext.Employees.FindAsync(id.Value); if (employee == null) { return(NotFound()); } var model = new LabourViewModel { Start = DateTime.Today, EmployeeId = employee.Id, LabourTypes = _combosHelper.GetComboLabourTypes() }; return(View(model)); }
public LabourViewModel ToLabourViewModel(Labour labour) { return(new LabourViewModel { Agendas = labour.Agendas, Start = labour.Start, Reports = labour.Reports, ImageUrl = labour.ImageUrl, Name = labour.Name, Employee = labour.Employee, LabourType = labour.LabourType, Activity = labour.Activity, Remarks = labour.Remarks, Id = labour.Id, EmployeeId = labour.Employee.Id, LabourTypeId = labour.LabourType.Id, LabourTypes = _combosHelper.GetComboLabourTypes() }); }