Exemplo n.º 1
0
        public override void Update(BusnesLogic.User user)
        {
            try
            {
                var locaUser = (from p in this.db.Users
                                where p.Id == user.Id
                                select p).First();
                locaUser.Name      = user.Name;
                locaUser.Email     = user.Email;
                locaUser.Skype     = user.Skype;
                locaUser.Signature = user.Signature;
                locaUser.Image     = user.UserImage;

                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                string error = "";
                foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                {
                    error += "\nObject: " + validationError.Entry.Entity.ToString();
                    foreach (DbValidationError err in validationError.ValidationErrors)
                    {
                        error += "\n" + err.ErrorMessage.ToString();
                    }
                }
                throw new Exception(error);
            }
        }
Exemplo n.º 2
0
 // us need more users
 public override void Add(BusnesLogic.User user)
 {
     try
     {
         db.Users.Add(user.ConvetToDUser());
         db.SaveChanges();
     }
     catch (DbEntityValidationException ex)
     {
         string error = "";
         foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
         {
             error += "\nObject: " + validationError.Entry.Entity.ToString();
             foreach (DbValidationError err in validationError.ValidationErrors)
             {
                 error += "\n" + err.ErrorMessage.ToString();
             }
         }
         throw new Exception(error);
     }
 }