public ActionResult <DayActivity> RemoveActivity(DateTime date, int activityId, TimeOfDay timeOfDay) { CustomDay dayToEdit = _customDayRepository.GetByDate(date); if (dayToEdit == null) { return(NotFound()); } else { DayActivity dayActivityToRemove = _dayActivityRepository.GetCustomDayActivity(date, timeOfDay, activityId); if (dayActivityToRemove == null) { return(NotFound()); } else { try { dayToEdit.RemoveDayActivity(dayActivityToRemove); _customDayRepository.SaveChanges(); return(Ok(dayActivityToRemove)); } catch (Exception ex) { return(BadRequest(ex.Message)); } } } }
public ActionResult <IEnumerable <Attendance> > GetAll(DateTime date, int activityId, TimeOfDay timeOfDay) { IEnumerable <Attendance> attendances = _dayActivityRepository.GetCustomDayActivity(date, timeOfDay, activityId)?.Attendances.ToList(); if (attendances == null) { return(NotFound()); } else { return(Ok(attendances)); } }