コード例 #1
0
        public void AddLog(Log log)
        {
            var timeLoggingContext = new TimeLoggingContext();

            timeLoggingContext.Logs.Add(log);
            timeLoggingContext.SaveChanges();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        public Log FindLog(int? id)
        {
            var timeLoggingContext = new TimeLoggingContext();

            return timeLoggingContext.Logs.Where(r => r.Id == id).SingleOrDefault<Log>();
        }