Ejemplo n.º 1
0
        public User CreateUser(User userToAdd)
        {
            if (userToAdd == null)
                return null;

            using (SUPERPEntities context = new SUPERPEntities(false))
            {
                userToAdd.Passwordhash = Encrypt.hashSHA256(userToAdd.Passwordhash);
                var u = context.Users.Add(userToAdd);
                context.SaveChanges();
                return u;
            }
        }
Ejemplo n.º 2
0
        private User CreateTestUser()
        {
            User newUser = new User();
            newUser.Firstname = "Eliott";
            newUser.Lastname = "Lujan";
            newUser.Passwordhash = "password";
            newUser.Zip_code = "33000";
            newUser.Address = "179 rue Camille Godard";
            newUser.City = "Bordeaux";
            newUser.Date_arrival = new DateTime(2010, 09, 01);
            newUser.Email = "*****@*****.**";

            return userService.CreateUser(newUser);
        }
Ejemplo n.º 3
0
 public User EditUser(User userToEdit)
 {
     return userBLL.EditUser(userToEdit);
 }
Ejemplo n.º 4
0
 public User CreateUser(User userToAdd)
 {
     return userBLL.CreateUser(userToAdd);
 }
Ejemplo n.º 5
0
        public User EditUser(User userToEdit)
        {
            if (userToEdit == null)
                return null;

            using (SUPERPEntities context = new SUPERPEntities(false))
            {
                var u = context.Users.Find(userToEdit.Id);
                if (u == null)
                    return null;

                u.Address = userToEdit.Address;
                u.Email = userToEdit.Email;
                u.Firstname = userToEdit.Firstname;
                u.Lastname = userToEdit.Lastname;

                if (userToEdit.Role != null)
                {
                    u.Role = context.Roles.Find(userToEdit.Role.Id);
                    u.Role_id = u.Role.Id;
                }

                u.Zip_code = userToEdit.Zip_code;
                u.City = userToEdit.City;
                context.SaveChanges();
                return u;
            }
        }