Example #1
0
        /// <summary>Create a new User on the service.</summary>
        /// <param name="newUser">The User object that should be created on the service.</param>
        public static void CreateUser(User newUser)
        {
            if (_sessionUser == null)
            {
                throw new NotLoggedInException();
            }

            if (_sessionUser.Type != UserType.admin)
            {
                throw new InsufficientRightsException();
            }

            if (newUser == null ||
                newUser.Email == null ||
                newUser.Password == null)
            {
                throw new InadequateObjectException();
            }

            if (UserExists(newUser.Email))
            {
                throw new KeyOccupiedException();
            }

            using (var client = new ServiceClient())
            {
                client.CreateUser(newUser);
            }
        }
        public string Register(Empleado emp)
        {
            ServiceClient service = new ServiceClient();

            service.CreateUser(emp);

            service.Close();

            return "Se ha creado el usuario con exito";
        }
Example #3
0
        public string Register(Empleado emp)
        {
            ServiceClient service = new ServiceClient();

            service.CreateUser(emp);

            service.Close();

            return("Se ha creado el usuario con exito");
        }
        public void TestSomeServiceCalls()
        {
            using (var svc = new ServiceClient())
            {
                //NOTE: Running this test twice will result in a duplicate error since two users can't have the same Id. This error
                //will be logged and can viewed in the LogEvent table as an error example.
                UserDTO rootUser = new UserDTO { Username = "******", Id = Guid.Parse("86f0f79c-3ae9-4393-a437-f691f408135f") };
                svc.CreateUser(rootUser);
                OrganizationDTO org = new OrganizationDTO { Name = "MyOrg" };
                var createdOrg = svc.CreateOrganization(org);
                createdOrg.Name = "BobsOrg";
                var updatedOrg = svc.UpdateOrganization(createdOrg);
                int deleted = svc.DeleteOrganizationById(updatedOrg.Id);

                OrganizationDTO newOrg = new OrganizationDTO { Name = "NewOrg" };
                var createdNewOrg = svc.CreateOrganization(newOrg);
            }
        }
Example #5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            client = new ServiceClient();
            Account account = new Account();

            account.Balance = 0.00M;
            User newUserObject = new User();

            newUserObject.FirstName   = userFirstNameInput.Text;
            newUserObject.LastName    = userLastNameInput.Text;
            newUserObject.UserName    = userUserNameInput.Text;
            newUserObject.Email       = userEmailInput.Text;
            newUserObject.PhoneNumber = userPhoneInput.Text;
            newUserObject.Account     = account;
            client.CreateUser(newUserObject);
            userViewList.Items.Add(newUserObject);
            userViewList.Items.Refresh();
            MessageBox.Show("User successfully created!");
        }
Example #6
0
        /// <summary>Create a new User on the service.</summary>
        /// <param name="newUser">The User object that should be created on the service.</param>
        public static void CreateUser(User newUser)
        {
            if (_sessionUser == null)
                throw new NotLoggedInException();

            if (_sessionUser.Type != UserType.admin)
                throw new InsufficientRightsException();

            if (newUser == null
                || newUser.Email == null
                || newUser.Password == null)
                throw new InadequateObjectException();

            if (UserExists(newUser.Email))
                throw new KeyOccupiedException();

            using (var client = new ServiceClient())
            {
                client.CreateUser(newUser);
            }
        }