public IEnumerable <IHour> GetHoursByVolunteer(int id) { IEnumerable <Hour> hours = _store.Hours .Include(e => e.Charity) .Include(e => e.Volunteer) .Where(e => e.VolunteerId == id) .ToList(); return(hours.Select(e => HourFactory.CreateHour(e))); }
public int CreateHour(IHour hourDTO) { Hour h = HourFactory.CreateHour(hourDTO); Charity c = _store.Charities.SingleOrDefault(e => e.Id == hourDTO.Charity.Id); if (c == null && hourDTO.Charity != null) { _store.Charities.Add(CharityFactory.CreateCharity(hourDTO.Charity)); } h.VolunteerId = hourDTO.Volunteer.Id; h.CharityId = hourDTO.Charity.Id; _store.Hours.Add(h); _store.SaveChanges(); return(h.Id); }
private ICronField ParseField(FieldLocation location, string field) { switch (location) { case FieldLocation.Minute: return(MinuteFactory.Parse(field)); case FieldLocation.Hour: return(HourFactory.Parse(field)); case FieldLocation.DayOfMonth: return(DayOfMonthFactory.Parse(field)); case FieldLocation.Month: return(MonthFactory.Parse(field)); case FieldLocation.DayOfWeek: return(DayOfWeekFactory.Parse(field)); default: throw new InvalidOperationException($"Unsupported field {location}"); } }