Exemple #1
0
 public Rating FindByIdEur(int ratingId)
 {
     using (var context = new EvenimenteEntities())
     {
         return(context.Ratings.FirstOrDefault(rating => rating.Id == ratingId));
     }
 }
 public void Add(Category category)
 {
     using (var context = new EvenimenteEntities())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
 public void Add(Event eveniment)
 {
     using (var context = new EvenimenteEntities())
     {
         context.Events.Add(eveniment);
         context.SaveChanges();
     }
 }
 public void Add(Comment comment)
 {
     using (var context = new EvenimenteEntities())
     {
         context.Comments.Add(comment);
         context.SaveChanges();
     }
 }
 public void Add(Picture picture)
 {
     using (var context = new EvenimenteEntities())
     {
         context.Pictures.Add(picture);
         context.SaveChanges();
     }
 }
 public void Add(Ticket ticket)
 {
     using (var context = new EvenimenteEntities())
     {
         context.Tickets.Add(ticket);
         context.SaveChanges();
     }
 }
Exemple #7
0
 public void Add(Rating rating)
 {
     using (var context = new EvenimenteEntities())
     {
         context.Ratings.Add(rating);
         context.SaveChanges();
     }
 }
 public void Add(Role role)
 {
     using (var contextEntities = new EvenimenteEntities())
     {
         contextEntities.Roles.Add(role);
         contextEntities.SaveChanges();
     }
 }
 public List <Ticket> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var tickets = context.Tickets;
         if (!tickets.Equals(null))
         {
             return(tickets.ToList());
         }
     }
     return(null);
 }
 public Picture FindByEventId(int eventId)
 {
     using (var context = new EvenimenteEntities())
     {
         var findPicture = context.Pictures.FirstOrDefault(picture => picture.EventId == eventId);
         if (findPicture != null)
         {
             return(findPicture);
         }
         throw new Exception("ERROR picture not found");
     }
 }
 public Category FindById(int categoryId)
 {
     using (var context = new EvenimenteEntities())
     {
         var findCategory = context.Categories.FirstOrDefault(category => category.Id == categoryId);
         if (findCategory == null)
         {
             throw new Exception("Category with this id could not be found");
         }
         return(findCategory);
     }
 }
 public Comment FindById(int commentId)
 {
     using (var context = new EvenimenteEntities())
     {
         var findComment = context.Comments.FirstOrDefault(comment => comment.Id == commentId);
         if (findComment != null)
         {
             return(findComment);
         }
     }
     throw new Exception("ERROR comment not found");
 }
 public Role FindByName(string name)
 {
     using (var contextEntities = new EvenimenteEntities())
     {
         var findRole = contextEntities.Roles.FirstOrDefault(role => role.Name == name);
         if (findRole != null)
         {
             return(findRole);
         }
         throw new Exception("ERROR roles not found");
     }
 }
Exemple #14
0
 public List <Rating> FindByIdE(int eventId)
 {
     using (var context = new EvenimenteEntities())
     {
         var ratings = context.Ratings.Where(rating => rating.EventId == eventId).ToList();
         if (!ratings.Equals(null))
         {
             return(ratings);
         }
     }
     throw new Exception("ERROR rating not found");;
 }
 public List <Event> GetAllMinAge(int minAge)
 {
     using (var context = new EvenimenteEntities())
     {
         var eventsList = (from eveniment in context.Events let dt = Convert.ToDateTime(eveniment.MinDateBirth) where VerifyAge(dt, minAge) select eveniment).ToList();
         if (eventsList.Count < 1)
         {
             throw new Exception("No events found");
         }
         return(eventsList);
     }
 }
 public Event FindById(int eventId)
 {
     using (var context = new EvenimenteEntities())
     {
         var findEveniment = context.Events.FirstOrDefault(@event => @event.Id == eventId);
         if (findEveniment != null)
         {
             return(findEveniment);
         }
         throw new Exception("ERROR event not found");
     }
 }
 public List <Event> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var events = context.Events;
         if (events.ToList().Count > 0)
         {
             return(events.ToList());
         }
         throw new Exception("ERROR events not found");
     }
 }
 public Ticket FindById(int ticketId)
 {
     using (var context = new EvenimenteEntities())
     {
         var findTicket = context.Tickets.FirstOrDefault(ticket => ticket.Id == ticketId);
         if (findTicket != null)
         {
             return(findTicket);
         }
     }
     return(null);
 }
 public List <Comment> FindByEventId(int eventId)
 {
     using (var context = new EvenimenteEntities())
     {
         var comments = context.Comments.Where(comment => comment.EventId == eventId).ToList();
         if (comments.Count > 0)
         {
             return(comments);
         }
     }
     throw new Exception("ERROR comments not found");
 }
 public List <Comment> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var comments = context.Comments;
         if (!comments.Equals(null))
         {
             return(comments.ToList());
         }
     }
     throw new Exception("ERROR comments not found");
 }
 public Role FindById(int roleId)
 {
     using (var contextEntities = new EvenimenteEntities())
     {
         var findRole = contextEntities.Roles.FirstOrDefault(role => role.Id == roleId);
         if (findRole != null)
         {
             return(findRole);
         }
     }
     throw new Exception("ERROR role not found");
 }
Exemple #22
0
 public List <Rating> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var ratings = context.Ratings;
         if (ratings.ToList().Count > 0)
         {
             return(ratings.ToList());
         }
     }
     throw new Exception("ERROR ratings not found");
 }
 public List <Picture> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var pictures = context.Pictures;
         if (pictures.ToList().Count > 1)
         {
             return(pictures.ToList());
         }
         throw new Exception("ERROR pictures not found");
     }
 }
 public List <Category> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var categories = context.Categories;
         if (categories.ToList().Count == 0)
         {
             throw new Exception("No category could be found");
         }
         return(categories.ToList());
     }
 }
 public User FindByUsername(string username)
 {
     using (var contextEntities = new EvenimenteEntities())
     {
         var users = contextEntities.Users.FirstOrDefault(userObj => userObj.Username == username);
         if (users == null)
         {
             throw new Exception("User with this username could not be found");
         }
         return(users);
     }
 }
 public User FindById(int userId)
 {
     using (var contextEntities = new EvenimenteEntities())
     {
         var users = contextEntities.Users.FirstOrDefault(user => user.Id == userId);
         if (users == null)
         {
             throw new Exception("User with this id could not be found");
         }
         return(users);
     }
 }
 public List <User> GetAll()
 {
     using (var context = new EvenimenteEntities())
     {
         var users = context.Users;
         if (users.ToList().Count > 0)
         {
             return(users.ToList());
         }
     }
     throw new Exception("No user could be found");
 }
 public void Delete(string username)
 {
     using (var contextEntities = new EvenimenteEntities())
     {
         var users = contextEntities.Users.FirstOrDefault(user => user.Username == username);
         if (users == null)
         {
             throw new Exception("User with this username could not be found");
         }
         contextEntities.Users.Remove(users);
         contextEntities.SaveChanges();
     }
 }
 public void Delete(int eventId)
 {
     using (var context = new EvenimenteEntities())
     {
         var toDeletEveniment = context.Events.FirstOrDefault(@event => @event.Id == eventId);
         if (toDeletEveniment == null)
         {
             return;
         }
         context.Events.Remove(toDeletEveniment);
         context.SaveChanges();
     }
 }
 public void Delete(int ticketId)
 {
     using (var context = new EvenimenteEntities())
     {
         var toDeleteTicket = context.Tickets.FirstOrDefault(ticket => ticket.Id == ticketId);
         if (toDeleteTicket == null)
         {
             return;
         }
         context.Tickets.Remove(toDeleteTicket);
         context.SaveChanges();
     }
 }