public LogEntry UpdateLog(LogEntry entry)
        {
            using (var fitnessLog = new Models.FitnessLog())
            {
                var log =
                    fitnessLog.Logs.Include("Entries")
                   .FirstOrDefault(l => l.Entries.Any(e => e.LogEntryID == entry.LogEntryID));
                if (log == null)
                    throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);

                var logEntry =
                    log.Entries.FirstOrDefault(e => e.LogEntryID == entry.LogEntryID);
                if (logEntry == null)
                    throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);

                logEntry.ExerciseName = entry.ExerciseName;
                logEntry.DateAndTime = entry.DateAndTime;
                logEntry.Lbs = entry.Lbs;
                logEntry.Reps = entry.Reps;
                logEntry.Set = entry.Set;
                logEntry.Log = log;

                fitnessLog.SaveChanges();

                return logEntry;
            }
        }
예제 #2
0
        public LogEntry UpdateLog(LogEntry entry)
        {
            using (var fitnessLog = new Models.FitnessLog())
            {
                var log =
                    fitnessLog.Logs.Include("Entries")
                    .FirstOrDefault(l => l.Entries.Any(e => e.LogEntryID == entry.LogEntryID));
                if (log == null)
                {
                    throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);
                }

                var logEntry =
                    log.Entries.FirstOrDefault(e => e.LogEntryID == entry.LogEntryID);
                if (logEntry == null)
                {
                    throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);
                }

                logEntry.ExerciseName = entry.ExerciseName;
                logEntry.DateAndTime  = entry.DateAndTime;
                logEntry.Lbs          = entry.Lbs;
                logEntry.Reps         = entry.Reps;
                logEntry.Set          = entry.Set;
                logEntry.Log          = log;

                fitnessLog.SaveChanges();

                return(logEntry);
            }
        }
 public IEnumerable<Log> GetFitnessLogs()
 {
     using (var fitnessLog = new Models.FitnessLog())
     {
         var logs = (from l in fitnessLog.Logs select l).ToList();
         return logs;
     }
 }
예제 #4
0
 public IEnumerable <Log> GetFitnessLogs()
 {
     using (var fitnessLog = new Models.FitnessLog())
     {
         var logs = (from l in fitnessLog.Logs select l).ToList();
         return(logs);
     }
 }