Esempio n. 1
0
        public static IEnumerable <RecordModel> GetRecords()
        {
            TimeTrackerDataContext dc = new TimeTrackerDataContext();
            var data = from r in dc.Records select new RecordModel(r.AppName, r.StartTime, r.EndTime, r.ID);

            return(data.AsEnumerable());
        }
Esempio n. 2
0
        public static void UpdateRecord(RecordModel record)
        {
            TimeTrackerDataContext dc = new TimeTrackerDataContext();
            var dane = from r in dc.Records
                       where (r.ID == record.Id)
                       select r;
            var dbRecord = dane.First();

            dbRecord.EndTime = record.EndTime;
            dc.SubmitChanges();
        }
Esempio n. 3
0
        public static void AddRecord(ref RecordModel record)
        {
            TimeTrackerDataContext dc = new TimeTrackerDataContext();
            Record dbRecord           = new Record
            {
                AppName   = record.AppName,
                StartTime = record.StartTime,
                EndTime   = record.EndTime
            };
            int lastId = (from r in dc.Records orderby r.ID descending select r.ID).SingleOrDefault();

            dbRecord.ID = lastId + 1;
            record.Id   = dbRecord.ID;
            dc.Records.InsertOnSubmit(dbRecord);
            dc.SubmitChanges();
        }