private void ButtonAdd_Click(object sender, EventArgs e) { if (AreParametersValid()) { Shift shift = new Shift(textBoxText.Text, StartDateAndTime, EndDateAndTime) { Color = panelColor.BackColor, Notes = richTextBox1.Text }; ShiftResult?.Invoke(shift); this.Close(); } }
public async Task <ActionResult <List <ShiftResult> > > GetShifts() { var results = new List <ShiftResult>(); var shifts = await _shiftsService.GetAllShiftsByDepartmentAsync(DepartmentId); foreach (var s in shifts) { var shiftData = await _shiftsService.PopulateShiftData(s, true, true, true, false, false); var shift = new ShiftResult(); shift.Id = shiftData.ShiftId; shift.Name = shiftData.Name; shift.Code = shiftData.Code; shift.Color = shiftData.Color; shift.SType = shiftData.ScheduleType; shift.AType = shiftData.AssignmentType; if (shiftData.Personnel != null) { shift.PCount = shiftData.Personnel.Count; } if (shiftData.Groups != null) { shift.GCount = shiftData.Groups.Count; } var nextDay = shiftData.GetNextShiftDayforDateTime(DateTime.UtcNow); if (nextDay != null) { shift.NextDay = nextDay.Day.ToString("O"); shift.NextDayId = nextDay.ShiftDayId; } if (s.Personnel != null && shiftData.Personnel.Any(x => x.UserId == UserId)) { shift.InShift = true; } results.Add(shift); } return(Ok(results)); }
public List <ShiftResult> GetShifts() { var results = new List <ShiftResult>(); var shifts = _shiftsService.GetAllShiftsByDepartment(DepartmentId); foreach (var s in shifts) { var shift = new ShiftResult(); shift.Id = s.ShiftId; shift.Name = s.Name; shift.Code = s.Code; shift.Color = s.Color; shift.SType = s.ScheduleType; shift.AType = s.AssignmentType; if (s.Personnel != null) { shift.PCount = s.Personnel.Count; } if (s.Groups != null) { shift.GCount = s.Groups.Count; } var nextDay = s.GetNextShiftDayforDateTime(DateTime.UtcNow); if (nextDay != null) { shift.NextDay = nextDay.Day.ToString("O"); shift.NextDayId = nextDay.ShiftDayId; } if (s.Personnel != null && s.Personnel.Any(x => x.UserId == UserId)) { shift.InShift = true; } results.Add(shift); } return(results); }
private void ButtonDelete_Click(object sender, EventArgs e) { ShiftResult?.Invoke(null); this.Close(); }