コード例 #1
0
ファイル: Tag.cs プロジェクト: comby-v/Projet.NET
 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;
 }
コード例 #2
0
ファイル: Location.cs プロジェクト: comby-v/Projet.NET
 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;
 }
コード例 #3
0
ファイル: User.cs プロジェクト: comby-v/Projet.NET
 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;
     }
 }
コード例 #4
0
ファイル: User.cs プロジェクト: comby-v/Projet.NET
        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;
            }
        }