Ejemplo n.º 1
0
        public static bool Create(T_Notification notification, T_User user, T_Event myevent)
        {
            using (ConcertFinderEntities bdd = new ConcertFinderEntities())
            {
                try
                {
                    T_Event a_event = bdd.T_Event.Where(x => x.Id == myevent.Id).FirstOrDefault();
                    T_User a_user = bdd.T_User.Where(x => x.Id == user.Id).FirstOrDefault();

                    bdd.Attach(a_event);
                    bdd.Attach(a_user);

                    notification.T_Event.Add(a_event);
                    notification.T_User.Add(a_user);

                    bdd.T_Notification.AddObject(notification);
                    bdd.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                   
                }
            }
            return true;
        }
Ejemplo n.º 2
0
 public static T_Tag Get(string tagName)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_Tag tag = bdd.T_Tag.Where(t => t.Name == tagName).FirstOrDefault();
             return tag;
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 3
0
 public static T_Tag GetTagbycontent(String content)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_Tag tag = bdd.T_Tag.Where(x => x.Name == content).FirstOrDefault();
             return tag;
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 4
0
 public static T_Tag Get(long id)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_Tag tag = bdd.T_Tag.Where(x => x.Id == id).FirstOrDefault();
             return tag;
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 5
0
 static public bool Delete(long id)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             bdd.DeleteObject(bdd.T_Location.Where(x => x.Id == id).FirstOrDefault());
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 6
0
 public static bool Create(T_Tag tag)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             bdd.AddToT_Tag(tag);
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 7
0
 public static List<DataAccess.T_Notification> GetNext(string pseudo, int last_id)
 {
     List<DataAccess.T_Notification> notifs;
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             notifs = bdd.T_Notification.Include("T_User").Include("T_Event").ToList().Where(x => x.T_User.FirstOrDefault().Pseudo == pseudo && x.Id < last_id).OrderByDescending(x => x.Date).Take(6).ToList();
         }
         catch (Exception)
         {
             throw;
         }
     }
     return notifs;
 }
Ejemplo n.º 8
0
 static public T_Location Get(long id)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         T_Location location;
         try
         {
             location = bdd.T_Location.Include("T_Event").
                 Where(x => x.Id == id).FirstOrDefault();
         }
         catch (Exception)
         {
             return null;
         }
         return location;
     }
 }
Ejemplo n.º 9
0
 public static T_Location GetLocationByCoord(double latitude, double longitude)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         T_Location location;
         try
         {
             location = bdd.T_Location.
                 Where(x => x.Latitude == latitude && x.Longitude == longitude).FirstOrDefault();
         }
         catch (Exception)
         {
             return null;
         }
         return location;
     }
 }
Ejemplo n.º 10
0
 static public bool Update(T_Location location)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             var n_location = new T_Location { Id = location.Id };
             bdd.T_Location.Attach(n_location);
             bdd.ApplyCurrentValues("T_Location", location);
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 11
0
 static public bool Update(T_Tag tag)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             var n_tag = new T_Tag { Id = tag.Id };
             bdd.T_Tag.Attach(n_tag);
             bdd.ApplyCurrentValues("T_Tag", tag);
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 12
0
 public static Boolean Update(T_User upUser)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities ())
     {
         try
         {
             var user = new T_User { Id = upUser.Id };
             bdd.T_User.Attach(user);
             bdd.ApplyCurrentValues("T_User", upUser);
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         return true;
     }
 }
Ejemplo n.º 13
0
        public static Boolean Delete(long idUser)
        {
            using (ConcertFinderEntities bdd = new ConcertFinderEntities())
            {
                try
                {
                    T_User user = bdd.T_User.Where(u => u.Id == idUser).FirstOrDefault();

                    user.Role = "deactivated";

                    bdd.AddToT_User(user);
                    bdd.SaveChanges();
                }
                catch (Exception)
                {
                    return false;
                }

                return true;
            }
        }
Ejemplo n.º 14
0
        public static bool Create(T_Notification notification, long id)
        {
            using (ConcertFinderEntities bdd = new ConcertFinderEntities())
            {
                try
                {
                    T_User user = bdd.T_User.Where(x => x.Id == id).FirstOrDefault();
                    bdd.Attach(user);
                    notification.T_User.Add(user);

                    bdd.AddToT_Notification(notification);
                    bdd.SaveChanges();
                }
                catch (Exception)
                {
                    throw;

                }
            }
            return true;
        }
Ejemplo n.º 15
0
 public static List<DataAccess.T_Notification> Get(string pseudo)
 {
     List<DataAccess.T_Notification> notifs = new List<T_Notification>();
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             notifs = bdd.T_Notification.Include("T_User").Include("T_Event").ToList().Where(x => x.T_User.FirstOrDefault().Pseudo == pseudo).OrderByDescending(x => x.Date).Take(6).ToList();
             foreach (T_Notification notif in bdd.T_Notification.Include("T_User").ToList().Where(x => x.T_User.FirstOrDefault().Pseudo == pseudo && x.Check == false).ToList())
             {
                 notif.Check = true;
             }
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
     return notifs;
 }
Ejemplo n.º 16
0
 public static Boolean Create(T_User user, List<T_Tag> tags)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             foreach (T_Tag tag in tags)
             {
                 bdd.Attach(tag);
                 user.T_Tag.Add(tag);
             }
             bdd.AddToT_User(user);
             bdd.SaveChanges();
         }
         catch (Exception)
         {
             throw;
            
         }
         return (true);
     }
 }
Ejemplo n.º 17
0
 public static bool Deny(T_Notification notif, long idEvent)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_Event myevent = bdd.T_Event.Include("T_User").Where(x => x.Id == idEvent).FirstOrDefault();
             notif.T_Event.Add(myevent);
             notif.T_User.Add(myevent.T_User);
             bdd.AddToT_Notification(notif);
             bdd.SaveChanges();
             return true;
         }
         catch (Exception)
         {
             throw;
             return false;
         }
     }
 }
Ejemplo n.º 18
0
 public static List<T_Tag> GetTagListFromUser(long idUser)
  {
      using (ConcertFinderEntities bdd = new ConcertFinderEntities())
      {
          try
          {
              T_User user = bdd.T_User.Where(x => x.Id == idUser).FirstOrDefault();
              List<T_Tag> tags = user.T_Tag.ToList();
              return tags;
          }
          catch (Exception)
          {
              return null;
          }
      }
  }
Ejemplo n.º 19
0
 public static T_User GetUserByEmail(String email)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             return (bdd.T_User.Where(u => u.Mail == email).FirstOrDefault());
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 20
0
 public static int Checks(String user)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             return bdd.T_User.Include("T_Notification").Where(x => x.Pseudo.Equals(user)).FirstOrDefault().T_Notification.Where(x => x.Check.Value == false).Count();
         }
         catch (Exception)
         {
             return 0;
         }
     }
 }
Ejemplo n.º 21
0
 public static Boolean ValidateUser(string pseudo, string password)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_User user = bdd.T_User.Where(x => x.Pseudo == pseudo && x.Password == password && x.Deleted == false) .FirstOrDefault();
             if (user != null)
             {
                 return true;
             }
             return false;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
Ejemplo n.º 22
0
 public static List<T_User> GetNextUsers(long last_id)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             return bdd.T_User.OrderByDescending(x => x.Id).Where(x => x.Deleted == false && x.Id < last_id).Take(16).ToList();
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 23
0
 public static T_User GetUserByPseudo(String pseudo)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_User user = bdd.T_User.Include("T_Tag").Include("T_Event").Where(x => x.Pseudo == pseudo).FirstOrDefault();
             if (user != null)
             {
                 return user;
             }
             return null;
         }
         catch (Exception)
         {
             throw;
           
         }
     }
 }
Ejemplo n.º 24
0
        public static Boolean Update(string pseudo, Models.ParameterModel form)
        {
            using (ConcertFinderEntities bdd = new ConcertFinderEntities())
            {
                try
                {

                    SimpleAES encryptor = new SimpleAES();
            
                    T_User user = bdd.T_User.Include("T_Tag").Include("T_Event").Where(x => x.Pseudo == pseudo).FirstOrDefault();

                    if (user.Ville != form.MyCity && form.MyCity != null)
                    {
                        user.Ville = form.MyCity;
                    }

                    if ((form.NewPassword != null) && (form.OldPassword != null) && (form.ConfirmPassword != null))
                    {
                        if (User.ValidateUser(pseudo, encryptor.EncryptToString(form.OldPassword)) && encryptor.EncryptToString(form.NewPassword) != user.Password)
                        {
                            user.Password = encryptor.EncryptToString(form.NewPassword);
                        }
                    }

                    if (user.Mail != form.Email && (form.Email != null))
                    {
                        user.Mail = form.Email;
                    }

                    List<DataAccess.T_Tag> listTag = new List<DataAccess.T_Tag>();
                    if (form.Tag != null)
                    {
                        
                        string[] split = form.Tag.Split(new Char[] { ' ', ',', '.', ';' });
                        foreach (string str in split)
                        {
                            if (str.Length > 2)
                            {
                                Regex r = new Regex("[a-z1-9*]");
                                Match m = r.Match(str);
                                if (m.Success)
                                {
                                    str.ToLower();
                                    DataAccess.T_Tag tag = new DataAccess.T_Tag()
                                    {
                                        Name = str
                                    };
                                    if (bdd.T_Tag.Where(t => t.Name == tag.Name).FirstOrDefault() == null)
                                    {
                                        DataAccess.Tag.Create(tag);
                                    }

                                    tag = bdd.T_Tag.Where(t => t.Name == tag.Name).FirstOrDefault();


                                    listTag.Add(tag);

                                }
                            }
                        }
                    }

                    
                    user.T_Tag.Clear();
                    foreach (T_Tag tag in listTag)
                    {
                        bdd.Attach(tag);
                        user.T_Tag.Add(tag);
                    }

                    var uuser = new T_User { Id = user.Id };
                   
                    bdd.ApplyCurrentValues("T_User", user);
                    bdd.SaveChanges();
                }
                catch (System.Data.UpdateException ex)
                {
                    throw;
                }
                return true;
            }
        }
Ejemplo n.º 25
0
 public static T_Location GetLocationById(long id)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         T_Location location;
         try
         {
             location = bdd.T_Location.Where(loc => loc.Id == id).FirstOrDefault();
         }
         catch (Exception)
         {
             return null;
         }
         return location;
     }
 }
Ejemplo n.º 26
0
 public static T_User Get(long idUser)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             return (bdd.T_User.Where(u => u.Id == idUser).FirstOrDefault());
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 27
0
 public static List<T_Event> getEventlistfromTag(long idTag)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             T_Tag tag = bdd.T_Tag.Where(x => x.Id == idTag).FirstOrDefault();
             List<T_Event> events = tag.T_Event.ToList();
             return events;
         }
         catch (Exception)
         {
             return null;
         }
     }
 }
Ejemplo n.º 28
0
 // Contains (Titre(mot), Salle) Start (Ville, Tag)
 public static List<T_Event> Search(String q)
 {
     using (ConcertFinderEntities bdd = new ConcertFinderEntities())
     {
         try
         {
             List<T_Event> events = bdd.T_Event.Include("T_Tag").Include("T_Location")
                 .Where(x => x.Valide == true && x.DateDebut > DateTime.Now).ToList()
                 .Where(x => x.Titre.Split(new char[] { ' ', '+' }).Intersect(q.Split(new char[] { ' ', '+' })).Count() > 0 ||
                     x.T_Location.Name.Split(' ').Select(z => z.ToLowerInvariant()).Intersect(q.Split(' ').Select(z => z.ToLowerInvariant())).Count() > 0 ||
                     x.T_Location.Ville.Split(new char[] { ' ', '-' }).Intersect(q.Split(new char[] { ' ', '-' })).Count() > 0 ||
                     x.T_Tag.FirstOrDefault(y => y.Name.Equals(q, StringComparison.InvariantCultureIgnoreCase)) != null)
                     .OrderBy(x => x.DateDebut).ToList();
             return events;
         }
         catch (Exception)
         {
             return null;
         }
     }
 }