public EventToManageLayer(Scene scene, Layer layer, RegistrationCommand command, bool raiseEvent) { Scene = scene; Layer = layer; Command = command; RaiseEvent = raiseEvent; }
public async Task <ActionResult> RegisterUser([FromBody] UserRegistrationModel userDto, CancellationToken cancellation) { try { var command = new RegistrationCommand(userDto); string token = await _mediator.Send(command, cancellationToken : cancellation); if (token is not null) { return(Ok(token)); } return(Unauthorized()); } catch (TaskCanceledException) { return(BadRequest("Canceled")); } catch (ValidationException exc) { return(BadRequest(exc.Message)); } catch (Exception e) { return(BadRequest("Something went wrong: " + e.Message)); } }
public void SetUpAsRemoveEvent( ComponentManager <TComponent> manager, string key) { Manager = manager; Key = key; Command = RegistrationCommand.Remove; }
public IInitialisationCommand CreateInitialisationCommand(XmlElement settings) { RegistrationCommand cmd = new RegistrationCommand(_transport, this); cmd.Status += RaiseIntermediateStatusEvent; ReadSettings(cmd, settings); return(cmd); }
public void SetUpAsAddEvent( ChildManagementMode managementMode, ChildTransformingMode transformingMode) { ManagementMode = managementMode; TransformingMode = transformingMode; Command = RegistrationCommand.Add; }
/// <summary> /// Remove player's registration (deregister). /// </summary> /// <param name="request">The request.</param> /// <returns>The <see cref="object"/>.</returns> public object Delete(RegistrationCommand request) { var result = GameController.Deregister(request.Slug); if (result) ServerEvents.NotifyChannel("spectator", new SpectatorMessage { MessageType = MessageTypes.Player, Name = request.Name, Avatar = request.Hash, Message = $"`@{request.Slug}` has left the demo" }); return new HttpResult(HttpStatusCode.NoContent); }
public void CanCreateRegistrationCommandTest() { var instance = new RegistrationCommand("or1", "dest1", "arr1"); Assert.IsNotNull(instance); Assert.AreEqual(instance.OriginUnlocode, "or1"); Assert.AreEqual(instance.DestinationUnlocode, "dest1"); Assert.AreEqual(instance.ArrivalDeadline, "arr1"); }
public void SetUpAsAddEvent( ComponentManager <TComponent> manager, TComponent component, string key) { Manager = manager; Component = component; Key = key; Command = RegistrationCommand.Add; }
public async Task <IActionResult> REGISTER([FromBody] RegistrationCommand command) { var response = await _mediator.Send(command); if (response.Status.IsSuccessful) { return(Ok(response)); } return(BadRequest(response)); }
public async Task <IActionResult> Register(RegistrationCommand registration) { if (registration == null) { return(BadRequest("Customer and Address not specified.")); } Customer entity = await _messaging.SendAsync(registration); return(Ok(CustomerResource.FromEntity(entity))); }
public IActionResult Registration([FromBody] RegistrationCommand registrationCommand) { var result = _authService.Registration(registrationCommand); if (result.RegistrationResult != RegistrationResult.Success) { return(BadRequest(result.RegistrationResult)); } return(Ok(result.RegistrationResult.GetStringValue())); }
public EventToManageObject( IImmediateObjectManager <TObject> objectManager, TObject content, RegistrationCommand command, bool raiseEvent) { ObjectManager = objectManager; Content = content; Command = command; RaiseEvent = raiseEvent; }
public RegistrationModel Registration(RegistrationCommand command) { EnsureIsValid(command); // TODO: Check user email and user login before add to database. var user = User.CreateUser(command.Login, command.FirstName, command.LastName, command.Email, command.Password); UnitOfWork.UserRepository.Add(user); return(new RegistrationModel(RegistrationResult.Success)); }
public async Task Handle_invalid_user_data(string customerId, string customerName, string customerEmail, string customerPhone, string customerAddress, string customerAdditionalAddress, string customerDistrict, string customerCity, string customerState, string customerZipCode) { //arrange var handler = new RegistrationCommandHandler(mediatorMock.Object, loggerMock.Object, claimsManagerMock.Object); RegistrationCommand command = new RegistrationCommand(customerId, customerName, customerEmail, customerPhone, customerAddress, customerAdditionalAddress, customerDistrict, customerCity, customerState, customerZipCode); IdentifiedCommand <RegistrationCommand, bool> request = new IdentifiedCommand <RegistrationCommand, bool>(command, Guid.NewGuid()); CancellationToken token = default(System.Threading.CancellationToken); //act //assert await Assert.ThrowsAsync <InvalidUserDataException>(() => handler.Handle(request, token)); }
public ActionResult Registration(RegistrationCommand command) { var message = string.Empty; if (_profileCondition.ValidateEmail(command.user_email)) { if (_profileCondition.ValidatePassword(command.user_password, ref message)) { if (_repository.GetUserByEmail(command.user_email) == null) { var user = new User { Email = command.user_email, Login = command.user_login, Password = _profileCondition.HashPassword(command.user_password), Hash = _profileCondition.GenerateHash(100), CreatedAt = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Activate = 0, LastLoginAt = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Token = _profileCondition.GenerateHash(40), RecoveryCode = 0, PublicToken = _profileCondition.GenerateHash(20), Profile = new Profile() }; user = _repository.AddUser(user); _mailer.SendEmail(user.Email, "Activate account", $"Activate account url: <a href=http://{_hostSettings.Ip}:{_hostSettings.PortHttp}" + $"/v1.0/users/Activate/?hash={user.Hash}>Activation url!</a>"); _logger.LogInformation("Create new user, id ->" + user.Id); return(Ok(new MessageResponse(true, "User account was successfully registrate. See your email to activate account by url."))); } else { message = "This email is already exists."; } } else { message = "Password not valid. " + message; } } else { message = $"Email -> {command.user_email} not valid."; } _logger.LogWarning(message); var response = new MessageResponse(false, message); return(StatusCode(500, response)); }
public async Task <IActionResult> RegisterAsync([FromForm] RegistrationCommand registerRequest) { if (ModelState.IsValid) { // Getting object that contain errors about login user data. ErrorResponce registerResponce = await _mediator.Send(registerRequest); if (ModelState.CheckErrors(registerResponce) == false) { return(RedirectToRoute("user", new { userName = registerRequest.UserName })); } } return(View(registerRequest)); }
private void SendRegistration(object sender, EventArgs eventArgs) { HideKeyboard(); var model = new RegistrationRequest(_name.Text, _secondName.Text, _email.Text, _password.Text, _town.Text); if (model.IsValid(ShowError)) { var commandDelegate = new CommandDelegate <RegistrationResponce>(OnSuccessRegistration, ShowError, ShowErrorNotEnternet); var command = new RegistrationCommand(LocalDb.Instance, commandDelegate); ThreadPool.QueueUserWorkItem(w => { ShowLoaderInMainThread(); command.Execute(model); DissmissLoaderInMainThread(); }); } }
public async Task <ActionResult <string> > Registration([FromBody] RegistrationCommand command) { try { var result = await Mediator.Send(command); return(new JsonResult(result)); } catch (Exception ex) { var message = new { message = ex.Message }; Response.StatusCode = 401; return(new JsonResult(message)); } }
public async Task ValidateAsync_ShouldFail_BadInput(string email, string nickname, string password) { //arrange UserRegistrationModel model = new() { Email = email, Nickname = nickname, Password = password }; //user is assumed not to present in the db _repoMock.Setup(x => x.CheckIsEmailPresent(email, CancellationToken.None)).ReturnsAsync(false); var command = new RegistrationCommand(model); //act ValidationResult result = await _systemUnderTesting.ValidateAsync(command, CancellationToken.None); //assert Assert.False(result.IsValid); }
public CloudClient(string host, bool enableLogs = false, string logName = null) { if (logName == null) { logName = DefaultLogName; } this.LogName = logName; this.Host = host; this._apiClient = (enableLogs ? new ApiClient(this.Host, logName) : new RestClient(this.Host)); this._apiClient.ClearHandlers(); this._apiClient.AddHandler("application/json", ApiSerializer); this._apiClient.AddHandler("text/json", ApiSerializer); this._signalRClient = new SignalRClient(this.Host, enableLogs, logName); this._loginCommand = new LoginCommand(); this._registrationCommand = new RegistrationCommand(); this._getCurrentAccountCommand = new GetCurrentAccountCommand(); }
public async Task Handle_success() { //arrange claimsManagerMock .Setup(c => c.AddUpdateClaim(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >())) .Returns(Task.CompletedTask) .Verifiable(); var handler = new RegistrationCommandHandler(mediatorMock.Object, loggerMock.Object, claimsManagerMock.Object); RegistrationCommand command = new RegistrationCommand("customerId", "customerName", "*****@*****.**", "phone", "address", "additionalAddress", "district", "city", "state", "12345-678"); IdentifiedCommand <RegistrationCommand, bool> request = new IdentifiedCommand <RegistrationCommand, bool>(command, Guid.NewGuid()); CancellationToken token = default(CancellationToken); //act var result = await handler.Handle(request, token); //assert Assert.True(result); claimsManagerMock.Verify(); }
private static bool ResumeWorkflow(Guid instanceId, RegistrationCommand command) { // Try to load the workflow and resume the bookmark var host = LoadRegistrationWorkflow(instanceId); var commandDone = new AutoResetEvent(false); // Run the workflow until idle, or complete host.Completed += completedEventArgs => commandDone.Set(); host.Idle += args => commandDone.Set(); Exception abortedException = null; host.Aborted += abortedEventArgs => { abortedException = abortedEventArgs.Reason; commandDone.Set(); }; // Resume the bookmark and Wait for the workflow to complete // ReSharper disable AssignNullToNotNullAttribute if (host.ResumeBookmark(command.ToString(), null) != BookmarkResumptionResult.Success) // ReSharper restore AssignNullToNotNullAttribute { throw new InvalidOperationException("Unable to resume registration process with command " + command); } if (!commandDone.WaitOne(Timeout)) { throw new TimeoutException("Timeout waiting to confirm registration"); } if (abortedException != null) { throw abortedException; } return(abortedException == null); }
public async Task <Customer> OnRegistration(RegistrationCommand command) { // Create domain entities from the command and associate them. var customer = Customer.Register(command.Prefix, command.FirstName, command.LastName, command.Age); var address = Address.Define(customer.Id, command.AddressLine1, command.AddressLine2, command.City, command.State, command.ZipCode); customer.AssignAddress(address); // Save the domain entities to the repository. await _customerRepo.SaveAsync(customer); // Notify other application components that a new registration was created. var domainEvent = new NewRegistrationEvent(customer); await _messaging.PublishAsync(domainEvent); return(customer); }
public void SetUpAsRemoveEvent() { Command = RegistrationCommand.Remove; }
public async Task <IActionResult> Register( string happening, [Bind(Prefix = "s")] string memberOverride, RegistrationViewModel model) { var status = await access.AuthenticateRequest(happening, memberOverride); switch (status) { case RegistrationAccessResult.NotYetOpen: return(View("RegistrationNotYetOpen")); case RegistrationAccessResult.AlreadyClosed: return(View("RegistrationAlreadyClosed")); case RegistrationAccessResult.DoesNotExist: return(NotFound()); default: break; } // TODO: Check, that given nickname is unique (or just let it be and add suffix automatically) if (!ModelState.IsValid) { return(View("Register", model)); } Guid registrationId = Guid.NewGuid(); logger.LogInformation("Received a new valid registration form. Assigning id " + registrationId); string emailValidationUrl = Url.Action( "Confirm", "Registration", new { happening = happening, id = registrationId }, Request.Scheme); var command = new RegistrationCommand { Id = registrationId, Happening = happening, Time = DateTime.UtcNow, Email = model.Email.Trim(), Mobile = model.Mobile.Trim(), Firstname = model.Firstname.Trim(), Lastname = model.Lastname.Trim(), Nickname = model.Nickname.Trim(), BeenThere = model.BeenThere, IsMember = !string.IsNullOrWhiteSpace(memberOverride), Info = model.Info, EmailValidationUrl = emailValidationUrl }; var result = await orchestrator.Register(command); switch (result) { case RegistrationResult.Duplicate: return(View("Duplicate")); case RegistrationResult.InternalError: return(View("Error")); case RegistrationResult.OK: default: logger.LogInformation(registrationId + ": Registration command sent to queue without errors, redirecting client."); return(RedirectToAction("WaitingForConfirmation")); } }
public async Task <ActionResult <User> > RegistrationAsync(RegistrationCommand command) { return(await Mediator.Send(command)); }
private static bool ResumeWorkflow(string email, RegistrationCommand command) { var instanceId = GetInstanceIdFromEmail(email); return(instanceId != Guid.Empty && ResumeWorkflow(instanceId, command)); }
public async Task <ActionResult <UserViewModel> > RegistrationAsync(RegistrationCommand command) { Thread.Sleep(5000); return(await Mediator.Send(command)); }
public EventToMangeDrawnFamilyship2D(DrawnObject2D parent, DrawnObject2D child) { Parent = parent; Child = child; Command = RegistrationCommand.Invalid; }
/// <summary> /// Register a player. /// </summary> /// <param name="request">The request.</param> /// <returns>The <see cref="object"/>.</returns> public object Post(RegistrationCommand request) { var result = GameController.Register(request.Slug, request.Hash, request.Name); if (!result) throw new HttpError(HttpStatusCode.NotAcceptable, "DuplicatePlayerID"); ServerEvents.NotifyChannel("spectator", new SpectatorMessage { MessageType = MessageTypes.Player, Name = request.Name, Avatar = request.Hash, Message = $"`@{request.Slug}` has joined the demo" }); return new HttpResult(HttpStatusCode.Created); }
public async Task <RegistrationResult> Register(RegistrationCommand cmd) { void log(string format, params object[] args) { logger.LogInformation("Register {0} ({1}): {2}", cmd.Id, cmd.Email, string.Format(format, args)); } log("Starting registration sequence"); // Duplicate detection based on email (used to be on the queue, now do dummily here) var all = await repository.All(cmd.Happening); if (all.Any(r => r.Email.Equals(cmd.Email, StringComparison.OrdinalIgnoreCase))) { logger.LogWarning("Register {0} ({1}): Duplicate registration detected", cmd.Id, cmd.Email); return(RegistrationResult.Duplicate); } var registrationEntity = new RegistrationEntity { PartitionKey = cmd.Happening, RowKey = cmd.Id.ToString(), Email = cmd.Email.ToLower(), Mobile = cmd.Mobile, Firstname = cmd.Firstname, Lastname = cmd.Lastname, Nickname = cmd.Nickname, Timestamp = cmd.Time, BeenThere = cmd.BeenThere, IsMember = cmd.IsMember, Info = cmd.Info }; var result = await repository.Add(registrationEntity); if (result.HttpStatusCode >= 300) { logger.LogError("Register {0} ({1}): Persisting registration to DB failed with status code {2}", cmd.Id, cmd.Email, result.HttpStatusCode); return(RegistrationResult.InternalError); } log("Registration persisted, HTTP Status code is {0}.", result.HttpStatusCode); // Send verification email - as this is not part of transaction doing this with queues would be pedant, but all of that was removed to reduce complexity. log("Sending verification email"); logger.LogDebug("Using email API key {0}", options.APIKey); var msg = MailHelper.CreateSingleEmail( from: new EmailAddress(options.FromAddress, options.FromDisplayName), to: new EmailAddress(cmd.Email, cmd.Firstname + " " + cmd.Lastname), subject: options.ConfirmationSubject, plainTextContent: string.Format(CultureInfo.CurrentCulture, options.ConfirmationTemplate, cmd.EmailValidationUrl), htmlContent: null); var response = await new SendGridClient(options.APIKey).SendEmailAsync(msg); if (response.StatusCode != System.Net.HttpStatusCode.Accepted) { logger.LogError("Register {0} ({1}): Email sending failed, SendGrid status code was {2}.", cmd.Id, cmd.Email, response.StatusCode); return(RegistrationResult.InternalError); } log("Email sent, SendGrid status code was {0}.", response.StatusCode); return(RegistrationResult.OK); }
public async Task <IActionResult> Registration([FromBody] RegistrationCommand value) { var result = await Mediator.Send(value); return(Ok(result)); }