public void AddLog(Log log) { var timeLoggingContext = new TimeLoggingContext(); timeLoggingContext.Logs.Add(log); timeLoggingContext.SaveChanges(); }
public static List<TimeLogViewModel> GetFiveLatestEntries() { var timeLoggingContext = new TimeLoggingContext(); var result = timeLoggingContext.Logs.Take(5).Select(l => new TimeLogViewModel() { UserId = l.UserId, StartTime = l.StartTime, EndTime = l.EndTime, Comment = l.Comment, Billable = l.Billable }); return result.ToList(); }
public static void SubmitTimeLog(TimeLogViewModel log) { var timeLoggingContext = new TimeLoggingContext(); var newEntry = new Log() { Billable = log.Billable, Comment = log.Comment, EndTime = log.EndTime, StartTime = log.StartTime, UserId = "doug" }; timeLoggingContext.Logs.Add(newEntry); timeLoggingContext.SaveChanges(); }
public List<Log> GetEntriesByDate(DateTime? dayInQuestion) { var day = DateTime.UtcNow; if (dayInQuestion.HasValue) day = dayInQuestion.Value; var context = new TimeLoggingContext(); var result = context.Logs.Where((r => (r.StartTime.Day == day.Day) && (r.StartTime.Month == day.Month) && (r.StartTime.Year == day.Year))); return result.ToList(); }
public Log FindLog(int? id) { var timeLoggingContext = new TimeLoggingContext(); return timeLoggingContext.Logs.Where(r => r.Id == id).SingleOrDefault<Log>(); }