示例#1
0
 public List <TimeEntry> List()
 {
     using (var db = new IzoneContext())
     {
         return(db.TimeEntries.Take(10).ToList());
     }
 }
示例#2
0
 double ITimeEntryRepository.TotalHours()
 {
     using (var db = new IzoneContext())
     {
         return(db.TimeEntries.Sum(x => x.Hours));
     }
 }
示例#3
0
 public List <Person> List()
 {
     using (var db = new IzoneContext())
     {
         return(db.People.ToList());
     }
 }
示例#4
0
 public Person GetBySlackUsername(string slackUsername)
 {
     using (var db = new IzoneContext())
     {
         return(db.People.Where(x => x.SlackUsername == slackUsername).FirstOrDefault());
     }
 }
示例#5
0
        public void SetSlackId(Person person)
        {
            using (var db = new IzoneContext())
            {
                var dbPerson = db.People.Where(x => x.SlackUsername == person.SlackUsername).FirstOrDefault();

                if (dbPerson == null)
                {
                    throw new Exception(string.Format("Cannot find Person having slack username '{0}'", person.SlackUsername));
                }

                dbPerson.SlackId = person.SlackId;
                db.Update(dbPerson);
                db.SaveChanges();
            }
        }