示例#1
0
 public IEnumerable <WorkoutEvent> GetAllActivities()
 {
     using (var db = new Juggle4Food_RunningEntities())
     {
         return(ConvertToWorkoutEvents((from e in db.RunningEvents
                                        orderby e.Date
                                        select e).ToList()));
     }
 }
示例#2
0
        public void UpdateActivity(WorkoutEvent activity)
        {
            var runningEvent = MapRunningEvent(activity);

            using (var db = new Juggle4Food_RunningEntities())
            {
                db.Entry(runningEvent).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
示例#3
0
 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()));
     }
 }
示例#4
0
 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()));
     }
 }
示例#5
0
 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()));
     }
 }
示例#6
0
        public int CreateActivity(WorkoutEvent activity)
        {
            var runningEvent = MapRunningEvent(activity);

            using (var db = new Juggle4Food_RunningEntities())
            {
                db.RunningEvents.Add(runningEvent);
                db.SaveChanges();
            }

            return(runningEvent.Id);
        }
示例#7
0
 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());
     }
 }
示例#8
0
 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());
     }
 }
示例#9
0
 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());
     }
 }
示例#10
0
        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();
                }
            }
        }
示例#11
0
        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);
        }