public IEnumerable <WorkoutEvent> GetAllActivities() { using (var db = new Juggle4Food_RunningEntities()) { return(ConvertToWorkoutEvents((from e in db.RunningEvents orderby e.Date select e).ToList())); } }
public void UpdateActivity(WorkoutEvent activity) { var runningEvent = MapRunningEvent(activity); using (var db = new Juggle4Food_RunningEntities()) { db.Entry(runningEvent).State = EntityState.Modified; db.SaveChanges(); } }
public IEnumerable <WorkoutEvent> GetActivitiesByDate(DateTime startDate, DateTime endDate) { using (var db = new Juggle4Food_RunningEntities()) { return(ConvertToWorkoutEvents((from e in db.RunningEvents where e.Date >= startDate && e.Date <= endDate orderby e.Date select e).ToList())); } }
public IEnumerable <WorkoutEvent> GetActivitiesByUser(string name) { using (var db = new Juggle4Food_RunningEntities()) { return(ConvertToWorkoutEvents((from e in db.RunningEvents where e.RunningPerson.Person.Equals(name, StringComparison.InvariantCultureIgnoreCase) orderby e.Date select e).ToList())); } }
public IEnumerable <WorkoutEvent> GetActivitiesByUser(int userId) { using (var db = new Juggle4Food_RunningEntities()) { return(ConvertToWorkoutEvents((from e in db.RunningEvents where e.RunningPerson.Id.Equals(userId) orderby e.Date select e).ToList())); } }
public int CreateActivity(WorkoutEvent activity) { var runningEvent = MapRunningEvent(activity); using (var db = new Juggle4Food_RunningEntities()) { db.RunningEvents.Add(runningEvent); db.SaveChanges(); } return(runningEvent.Id); }
public IEnumerable <ActivityType> GetActivityTypes() { using (var db = new Juggle4Food_RunningEntities()) { return((from a in db.RunningActivities orderby a.Id select new ActivityType() { Id = a.Id, Name = a.Activity }).ToList()); } }
public IEnumerable <UnitOfMeasurement> GetUnitOfMeasurements() { using (var db = new Juggle4Food_RunningEntities()) { return((from a in db.RunningUnits orderby a.Id select new UnitOfMeasurement() { Id = a.Id, Name = a.Unit }).ToList()); } }
public IEnumerable <User> GetUsers() { using (var db = new Juggle4Food_RunningEntities()) { return((from a in db.RunningPersons orderby a.Id select new User() { Id = a.Id, Name = a.Person }).ToList()); } }
public void DeleteActivity(int id) { using (var db = new Juggle4Food_RunningEntities()) { var runningEvent = db.RunningEvents.Find(id); if (runningEvent != null) { db.RunningEvents.Remove(runningEvent); db.SaveChanges(); } } }
public WorkoutEvent ReadActivity(int id) { var workoutEvent = new WorkoutEvent(); using (var db = new Juggle4Food_RunningEntities()) { var runningEvent = db.RunningEvents.Find(id); if (runningEvent != null) { workoutEvent = MapWorkoutEvent(runningEvent); } } return(workoutEvent); }