예제 #1
0
 public IEnumerable <Model.TimeZone> GetByOwner(string owner)
 {
     using (var context = new TimeZoneManagerEntities())
     {
         return(context.TimeZones.Where(e => e.Owner == owner).ToList());
     }
 }
예제 #2
0
 public Model.TimeZone GetByID(int id)
 {
     using (var context = new TimeZoneManagerEntities())
     {
         return(context.TimeZones.SingleOrDefault(e => e.ID == id));
     }
 }
예제 #3
0
 public IEnumerable <Model.TimeZone> GetAll()
 {
     using (var context = new TimeZoneManagerEntities())
     {
         return(context.TimeZones.ToList());
     }
 }
예제 #4
0
        public Model.TimeZone Add(Model.TimeZone entity)
        {
            using (var context = new TimeZoneManagerEntities())
            {
                context.TimeZones.Add(entity);
                context.SaveChanges();

                return(entity);
            }
        }
예제 #5
0
        public void Remove(int id)
        {
            using (var context = new TimeZoneManagerEntities())
            {
                var entity = context.TimeZones.Single(e => e.ID == id);

                if (entity != null)
                {
                    context.TimeZones.Remove(entity);
                    context.SaveChanges();
                }
            }
        }
예제 #6
0
        public void Update(Model.TimeZone entity)
        {
            using (var context = new TimeZoneManagerEntities())
            {
                var entityToUpdate = context.TimeZones.SingleOrDefault(e => e.ID == entity.ID);
                if (entityToUpdate != null)
                {
                    entityToUpdate.Name      = entity.Name;
                    entityToUpdate.City      = entity.City;
                    entityToUpdate.GMTOffset = entity.GMTOffset;

                    context.SaveChanges();
                }
            }
        }