示例#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;
        }
示例#2
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;
     }
 }
示例#3
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);
     }
 }
示例#4
0
        public ActionResult CreateEvent(FormEventModels form)
        {
            if (ModelState.IsValid && User.Identity.IsAuthenticated)
            {
                if (form.Id == 0)
                {
                    DataAccess.T_User user = BusinessManagement.User.GetUserByPseudo(User.Identity.Name);
                    if (user != null && BusinessManagement.Event.Create(form, user))
                    {
                        DataAccess.T_Event bdd_event = BusinessManagement.Event.Get(form.Title, true);
                        BusinessManagement.Notification.Create(user, bdd_event);
                        return RedirectToAction("Detail", "Event", new { id = bdd_event.Id, creation = true });
                    }
                    else
                    {
                        return View("Error");
                    }
                }
                else
                {
                    DataAccess.T_User user = new T_User();
                    user = BusinessManagement.User.GetUserByPseudo(User.Identity.Name);
                     
                    if (user != null && BusinessManagement.Event.Update(form, User.Identity.Name))
                    {
                        DataAccess.T_Event bdd_event = BusinessManagement.Event.Get(form.Id, true);
                        BusinessManagement.Notification.Update(user, bdd_event);
                        return RedirectToAction("Detail", "Event", new { id = bdd_event.Id, creation = true });
                    }
                }

            }
            return View(form);
        }
示例#5
0
        public static List<EventItem> GetListEventByUserTag (T_Event myevent, T_User user, int nb)
        {
            List<EventItem> listRes = new List<EventItem>();
            List<T_Event> listEvent = new List<T_Event>();

            listEvent = DataAccess.Event.GetListEventByUserTag(myevent, user, nb);
            foreach (T_Event myev in listEvent)
            {
                EventItem eventItem = new EventItem()
                {
                    Id = myev.Id,
                    Titre = myev.Titre,
                    Description = myev.Description,
                    Type = myev.Type,
                    StartDate = myev.DateDebut,
                    EndDate = myev.DateFin.GetValueOrDefault(),
                    Salle = myev.T_Location.Name,
                    Email = myev.Email,
                    Tel = myev.Tel,
                    Website = myev.WebSite,
                    CP = myev.T_Location.CP,
                    Ville = myev.T_Location.Ville,
                    Rue = myev.T_Location.Rue
                };
                ServerPathImage(myev, eventItem);
                listRes.Add(eventItem);
            }

            return listRes;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the T_User EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToT_User(T_User t_User)
 {
     base.AddObject("T_User", t_User);
 }
 /// <summary>
 /// Create a new T_User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="firstname">Initial value of the Firstname property.</param>
 /// <param name="mail">Initial value of the Mail property.</param>
 /// <param name="pseudo">Initial value of the Pseudo property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="role">Initial value of the Role property.</param>
 /// <param name="deleted">Initial value of the Deleted property.</param>
 public static T_User CreateT_User(global::System.Int64 id, global::System.String name, global::System.String firstname, global::System.String mail, global::System.String pseudo, global::System.String password, global::System.String role, global::System.Boolean deleted)
 {
     T_User t_User = new T_User();
     t_User.Id = id;
     t_User.Name = name;
     t_User.Firstname = firstname;
     t_User.Mail = mail;
     t_User.Pseudo = pseudo;
     t_User.Password = password;
     t_User.Role = role;
     t_User.Deleted = deleted;
     return t_User;
 }
示例#8
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;
            }
        }
示例#9
0
 static public bool BlockUser(long Id)
 {
     T_User user = new T_User();
     try
     {
         user = Get(Id);
         user.Deleted = true;
         return (Update(user));
     }
     catch (Exception)
     {
         return false;
     }
 }