Exemplo n.º 1
0
 public void Add(EventCheckInModel checkIn)
 {
     using (var db = new HIPContext())
     {
         db.EventCheckIns.Add(checkIn);
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void Update(EventModel eventModel)
 {
     using (var db = new HIPContext())
     {
         var events = db.Events.Attach(eventModel);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public UserModel Get(string email)
        {
            using (var db = new HIPContext())
            {
                var users = db.Users
                            .Where(b => b.Email == email)
                            .ToList();

                return(users.ElementAt(0));
            }
        }
Exemplo n.º 4
0
 public EventModel Get(string id)
 {
     using (var db = new HIPContext())
     {
         var events = db.Events
                      .Where(b => b.Id == id)
                      .Include(e => e.RecurringOccurrences)
                      .Include(e => e.Occurrences)
                      .Include(e => e.Blackouts)
                      .ToList();
         return(events.Count() > 0 ? events.ElementAt(0) : null);
     }
 }
Exemplo n.º 5
0
 public void Update(UserModel user)
 {
     if (user.Email == null || user.ParentEmail == null)
     {
         throw new Exception("in order to update a user, and email must be present");
     }
     if (user.FirstName == null || user.LastName == null)
     {
         throw new Exception("in order to update an existing user, both first and last names must be provided");
     }
     using (var db = new HIPContext())
     {
         var users = db.Users.Attach(user);
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public void Add(UserModel user)
 {
     using (var db = new HIPContext())
     {
         var existingUsers = db.Users.Where(u => u.Email == user.Email).ToList();
         if (existingUsers != null && existingUsers.Count() > 0)
         {
             Update(existingUsers.First());
         }
         else
         {
             db.Users.Add(user);
             db.SaveChanges();
         }
     }
 }
Exemplo n.º 7
0
 public void Add(EventModel eventModel)
 {
     try
     {
         using (var db = new HIPContext())
         {
             db.Events.Add(eventModel);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemplo n.º 8
0
        public IEnumerable <EventModel> GetAll()
        {
            using (var db = new HIPContext())
            {
                try
                {
                    var events = db.Events
                                 .Include(e => e.RecurringOccurrences)
                                 .Include(e => e.Occurrences)
                                 .Include(e => e.Blackouts)
                                 .ToList();

                    return(events);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }