Ejemplo n.º 1
0
        private async void buttonCreate_Click(object sender, EventArgs e)
        {
            var userInfo = getUserInfo();

            await invoke($"Create {userInfo.UserName}", async() => {
                await _users.Create(userInfo);
            });
        }
Ejemplo n.º 2
0
 public IActionResult Create(UserRegistration empdetails)
 {
     try
     {
         usermanagement.Create(empdetails);
         return(CreatedAtRoute("Getempdetails", new { id = empdetails.Id.ToString() }, empdetails));
     }
     catch (Exception ex)
     {
     }
     return(Ok());
 }
        public async Task <UserProperty> Handle(RegisterUserCommand request, CancellationToken cancellationToken)
        {
            var model = new UserProperty();

            model.FirstName = request.FirstName;
            model.LastName  = request.LastName;
            model.Username  = request.Username;
            model.Email     = request.Email;
            model.Role      = Role.User;

            var user = await _services.Create(model, request.Password, cancellationToken);

            return(user);
        }
 public IActionResult Post([FromBody] User user)
 {
     try
     {
         User userCreated = userManagement.Create(user);
         return(CreatedAtRoute("user", new { id = user.Id }, UserModelForResponse.ToModel(userCreated)));
     }
     catch (DomainBusinessLogicException e)
     {
         return(BadRequest(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Ejemplo n.º 5
0
        private async Task OnSave(object obj)
        {
            Errors = User.Validate().ToList();

            CheckPassword();

            if (Errors.Any())
            {
                return;
            }

            User.Password = Password?.GetStringValue();

            ResponseModel response;

            if (User.Id <= 0)
            {
                response = await _userManager.Create(User);
            }
            else
            {
                response = await _userManager.Update(User);
            }

            if (!response.IsSuccess)
            {
                if (response.Message.Equals("Username is already taken", StringComparison.OrdinalIgnoreCase))
                {
                    Errors.Add(l10n.UserView.Errors.UsernameIsTaken);
                }
                else
                if (response.Message.Equals("Username is already taken", StringComparison.OrdinalIgnoreCase))
                {
                    Errors.Add(l10n.UserView.Errors.EmailIsTaken);
                }
                else
                {
                    Errors.Add(l10n.Shared.Errors.InternalAppError);
                }

                OnPropertyChanged(nameof(Errors));
                return;
            }

            _mediator.Raise(UserManagementViewModel.UserSavedOperationKey, User);
        }
Ejemplo n.º 6
0
        public async Task RunMajorUseCasesWithDummyUser()
        {
            var config = new FConfig()
            {
                TcpPort = 0
            };
            var dummyUsers = new DummyUsers();

            var             fserver = new FServer(Logger.Null, config, dummyUsers);
            IUserManagement users   = fserver;

            await users.Create(_goga);

            await users.Update(_goga);

            var all = await users.List();

            Assert.That(all, Is.Not.Empty);

            var fclient = await FClient.New(config, new ClientInfo {
                ServerName = fserver.ServerName,
                Port       = fserver.Port,
                UserName   = "******",
                Password   = "******"
            });

            await fclient.Upload("f-config.goga.json", "f-config.json");

            await fclient.Upload("NUnit3.TestAdapter.dll.goga", "NUnit3.TestAdapter.dll");

            await fclient.Download("f-config.goga.json", "f-config.copy.json");

            await fclient.Download("NUnit3.TestAdapter.dll.goga", "NUnit3.TestAdapter.dll.copy");

            var list = await fclient.ListFiles();

            Assert.That(list, Is.Not.Empty);

            await fclient.Delete("f-config.goga.json");

            await users.Delete(_goga, false);
        }