Exemplo n.º 1
0
        public MembershipCreateStatus CreateUser(string userName, string password, string email, string lastName, Guid roleId, DateTime dateOfBirth)
        {
            if (String.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("Value cannot be null or empty.", "userName");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentException("Value cannot be null or empty.", "password");
            }
            if (String.IsNullOrEmpty(email))
            {
                throw new ArgumentException("Value cannot be null or empty.", "email");
            }

            MembershipCreateStatus status;
            var user = _provider.CreateUser(userName, password, email, null, null, true, null, out status);

            ICommand command;

            if (user != null && user.ProviderUserKey != null)
            {
                var userId = new Guid();
                Guid.TryParse(user.ProviderUserKey.ToString(), out userId);

                command = new ChangeUserInformation(new UserId(userId), null, null, userName, lastName, dateOfBirth);
                _commandSender.Send(command);

                command = new AddRoleToUser(new UserId(userId), roleId);
                _commandSender.Send(command);
            }

            return(status);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateDetails([FromBody] UpdateLanguageDetails model)
        {
            model.SiteId = SiteId;
            await Task.Run(() => _commandSender.Send <UpdateLanguageDetails, Language>(model));

            return(new NoContentResult());
        }
        public async Task <IActionResult> Post([FromBody] CreateFeeModel createFeeModel)
        {
            await _commandSender.Send(new CreateFeeCommand(Guid.NewGuid(), createFeeModel.FeeId, createFeeModel.Tag,
                                                           createFeeModel.Cost));

            return(Ok());
        }
        public async Task <IActionResult> AddGameSummary([FromBody] CreateGameSummaryRequest request)
        {
            BaseballPlayRM lastPlayOfGame = null;
            var            lastPlayKey    = Dictionaries.cdBaseballPlayRM.Keys.FirstOrDefault(k => k.StartsWith(request.RetrosheetGameId));

            if (!string.IsNullOrEmpty(lastPlayKey))
            {
                Dictionaries.cdBaseballPlayRM.TryRemove(lastPlayKey, out lastPlayOfGame);
            }

            if (lastPlayOfGame == null || !lastPlayOfGame.EndOfGame)
            {
                request.HasValidationErrors = true;
            }
            else
            {
                request.HasValidationErrors = false;
                request.HomeTeamFinalScore  = lastPlayOfGame.EndOfPlay_HomeScore;
                request.AwayTeamFinalScore  = lastPlayOfGame.EndOfPlay_VisitorScore;
                request.HomeTeamBatsFirst   = (lastPlayOfGame.TeamAtBat == "V" && lastPlayOfGame.IsBottomHalf == true) || (lastPlayOfGame.TeamAtBat == "H" && lastPlayOfGame.IsBottomHalf == false);
            }
            request.GameDay = request.RetrosheetGameId.Substring(3, 8);
            var cmd = _mapper.Map <CreateGameSummaryCommand>(request);
            await _commandSender.Send(cmd);

            return(Ok());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Save(CreateModuleType model)
        {
            model.Id = Guid.NewGuid();
            await Task.Run(() => _commandSender.Send <CreateModuleType, ModuleType>(model));

            return(new NoContentResult());
        }
Exemplo n.º 6
0
 public IActionResult Register([FromBody] RegistrationFormDataViewModel model)
 {
     if (ModelState.IsValid)
     {
         var result         = new { Succeeded = true };
         var passwordHasher = new PasswordHasher <string>();
         _commandSender.Send(new RegisterUserCommand
         {
             Email        = model.Email,
             PasswordHash = passwordHasher.HashPassword(model.Email, model.Password),
             UserName     = model.UserName,
             FirstName    = model.FirstName,
             LastName     = model.LastName
         });
         if (result.Succeeded)
         {
             return(Ok(new RegistrationResponseViewModel()));
         }
         else
         {
             var response = new RegistrationResponseViewModel
             {
                 //IsLockedOut = result.IsLockedOut,
                 //IsNotAllowed = result.IsNotAllowed,
                 //RequiresTwoFactor = result.RequiresTwoFactor,
             };
             return(BadRequest(response));
         }
     }
     else
     {
         return(BadRequest("Error"));
     }
 }
Exemplo n.º 7
0
        public async Task <IActionResult> CreateInventoryItem([FromBody] CreateInventoryItemRequest request, CancellationToken cancellationToken)
        {
            var id = Guid.NewGuid();
            await _commandSender.Send(new CreateInventoryItem(id, request.Name), cancellationToken);

            return(Ok(id));
        }
Exemplo n.º 8
0
        public async Task <PlacesSyncReponseModel> SyncPlaces(int skipIndex, int takeIndex, bool isCities)
        {
            try
            {
                var queryResult = await _querySender.Send(new GetAllPlacesQuery
                {
                    IsFeel    = true,
                    SkipIndex = skipIndex,
                    TakeIndex = takeIndex,
                    IsCities  = isCities
                });

                if (!isCities)
                {
                    AlgoliaPlaceSyncCommandResult result = await _commandSender.Send <AlgoliaPlaceSyncCommand, AlgoliaPlaceSyncCommandResult>(new AlgoliaPlaceSyncCommand { AllPlaces = queryResult.AllPlaces, ModifiedBy = new Guid("D21A85EE-351C-4349-9953-FE1492740976") }, new TimeSpan(2, 0, 0));
                }
                else
                {
                    AlgoliaCitiesSyncCommandResult result = await _commandSender.Send <AlgoliaCitiesSyncCommand, AlgoliaCitiesSyncCommandResult>(new AlgoliaCitiesSyncCommand { AllCities = queryResult.GetAllCities, ModifiedBy = new Guid("D21A85EE-351C-4349-9953-FE1492740976") }, new TimeSpan(2, 0, 0));
                }
                return(new PlacesSyncReponseModel
                {
                    IsSuccess = true,
                    AllPlaces = queryResult.AllPlaces
                });
            }
            catch (Exception ex)
            {
                return(new PlacesSyncReponseModel
                {
                    IsSuccess = false
                });
            }
        }
Exemplo n.º 9
0
        public async Task <IHttpActionResult> Post(
            [FromBody] Order newOrder,
            [FromHeader] Guid clientRequestId,
            [RequestChecksum] string idempotencyToken,
            ODataQueryOptions <Order> options,
            CancellationToken cancellationToken,
            bool reserveOnly = false)
        {
            var builder = new OrderBuilder().ForCatalogItem(newOrder.CatalogId)
                          .WithQuantity(newOrder.Quantity)
                          .CorrelatedBy(clientRequestId.ToString())
                          .HasIdempotencyToken(idempotencyToken);

            if (reserveOnly)
            {
                builder.ReserveTokensOnly();
            }

            using (var circuitBreaker = this.NewCircuitBreaker(cancellationToken))
            {
                builder.ForBillingAccount(await accounts.FindBusinessAccount(User, circuitBreaker.Token));

                var placeOrder = builder.NewPlaceOrder();

                await bus.Send(placeOrder, circuitBreaker.Token);

                newOrder.Id = placeOrder.AggregateId;
                newOrder.BillingAccountId = placeOrder.BillingAccountId;

                return(await circuitBreaker.CreatedOrAccepted(newOrder, ct => repository.GetSingleAsync(t => t.Id == newOrder.Id, ct)));
            }
        }
Exemplo n.º 10
0
        public ActionResult Profile(ProfileViewModel model)
        {
            if (model == null)
            {
                //TODO: return error message.
                return(View());
            }
            if (!ModelState.IsValid)
            {
                //TODO: return error message.
                return(View("EditProfile", model));
            }

            var userInfo = _userQueryService.GetUser(new UserId(UserContext.Current.UserId));

            if (userInfo == null)
            {
                //TODO: return error message.
                return(RedirectToAction("Profile", new { id = UserContext.Current.UserId }));
            }

            if (userInfo.FirstName != model.FirstName || userInfo.LastName != model.LastName || userInfo.Phone != model.Phone || userInfo.DateOfBirth != model.DateOfBirth)
            {
                var command = new ChangeUserInformation(new UserId(userInfo.UserId), model.Phone, userInfo.Image, model.FirstName,
                                                        model.LastName, model.DateOfBirth);
                _cmdSender.Send(command);

                UserContext.IsUpdated = false;
            }

            return(RedirectToAction("Profile", new { id = userInfo.UserId }));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create(CreateLocationRequest request)
        {
            var command = _mapper.Map <CreateLocationCommand>(request);
            await _commandSender.Send(command);

            return(Ok());
        }
        public IActionResult Post([FromBody] JournalEntry journalEntry)
        {
            if (journalEntry == null || journalEntry.EventDate == null ||
                journalEntry.Splits == null || journalEntry.Splits.Count < 2)
            {
                return(BadRequest());
            }

            string userId = _httpContextAccessor.HttpContext.User.Claims
                            .Where(c => c.Type == Constants.ClaimType)
                            .Select(c => c.Value).SingleOrDefault();
            BookDto book = _readmodel.Find("UserId", userId);

            if (book == null)
            {
                Guid journalEntryId = Guid.NewGuid();
                _commandSender.Send(new CreateJournal(journalEntryId, userId, journalEntry));
                _logger.LogInformation(LoggingEvents.INSERT_ITEM, "Item {0} Added. New Book", journalEntryId);
            }
            else
            {
                _commandSender.Send(new AddJournalEntry(book.AggregateId, userId, journalEntry));
                _logger.LogInformation(LoggingEvents.UPDATE_ITEM, "Item {0} Added", book.AggregateId);
            }

            return(new OkResult());
        }
Exemplo n.º 13
0
        public async Task <ReviewsRatingResponseViewModel> SaveReviewRating([FromBody] ReviewsRatingDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _commandSender.Send(new ReviewsRatingCommand
                    {
                        UserAltId  = new Guid(model.UserAltId.ToString()),
                        EventAltId = new Guid(model.EventAltId.ToString()),
                        Points     = model.Points,
                        Comment    = model.Comment,
                        IsEnabled  = true,
                    });

                    return(new ReviewsRatingResponseViewModel {
                        Success = true
                    });
                }
                catch (Exception ex)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, ex);
                    return(new ReviewsRatingResponseViewModel {
                        Success = false
                    });
                }
            }
            else
            {
                return(new ReviewsRatingResponseViewModel {
                    Success = false
                });
            }
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Post([FromBody] CreateSite model)
        {
            model.Id = Guid.NewGuid();
            await Task.Run(() => _commandSender.Send <CreateSite, Site>(model));

            return(new NoContentResult());
        }
Exemplo n.º 15
0
 public IActionResult Save(CreateEmailAccount model)
 {
     model.SiteId = SiteId;
     model.Id     = Guid.NewGuid();
     _commandSender.Send <CreateEmailAccount, EmailAccount>(model);
     return(new NoContentResult());
 }
Exemplo n.º 16
0
        public IHttpActionResult Create(CreateLocationRequest request)
        {
            var command = _mapper.Map <CreateLocationCommand>(request);

            _commandSender.Send(command);
            return(Ok());
        }
Exemplo n.º 17
0
        public async Task <IHttpActionResult> Post(
            [FromBody] MintRequest newRequest,
            [FromHeader] Guid clientRequestId,
            [RequestChecksum] string idempotencyToken,
            ODataQueryOptions <MintRequest> options,
            CancellationToken cancellationToken)
        {
            var builder = new MintBuilder().ForCatalogItem(newRequest.CatalogId)
                          .WithQuantity(newRequest.Quantity)
                          .CorrelatedBy(clientRequestId.ToString())
                          .HasIdempotencyToken(idempotencyToken);

            using (var circuitBreaker = this.NewCircuitBreaker(cancellationToken))
            {
                builder.ForBillingAccount(await accounts.FindBusinessAccount(User, circuitBreaker.Token));

                var mint = builder.NewMint();

                await bus.Send(mint, circuitBreaker.Token);

                newRequest.Id = mint.AggregateId;

                return(await circuitBreaker.CreatedOrAccepted(newRequest, ct => repository.GetSingleAsync(t => t.Id == newRequest.Id, ct)));
            }
        }
Exemplo n.º 18
0
        public async Task <IActionResult> Post([FromBody] CreatePage model)
        {
            model.SiteId = SiteId;
            await Task.Run(() => _commandSender.Send <CreatePage, Page>(model));

            return(new NoContentResult());
        }
Exemplo n.º 19
0
        public IHttpActionResult Post(LoanRequest loanRequest)
        {
            var userId = Guid.NewGuid();

            _command.Send(new ApplyForLoan()
            {
                //Apr = loanRequest.LoanDetails.Apr,
                //MonthlyPayment = loanRequest.LoanDetails.MonthlyCost,
                //LoanAmount = loanRequest.LoanDetails.LoanAmount,
                //Term = loanRequest.LoanDetails.Term,

                UserId = userId
            });

            _command.Send(new UserRegister()
            {
                Title                       = loanRequest.UserDetails.Title,
                Firstname                   = loanRequest.UserDetails.Firstname,
                Lastname                    = loanRequest.UserDetails.Lastname,
                Email                       = loanRequest.UserDetails.Email,
                PhoneNumber                 = loanRequest.UserDetails.PhoneNumber,
                DoB                         = loanRequest.UserDetails.DoB,
                AnnualIncomeBeforeTax       = loanRequest.FinancialDetails.AnnualIncomeBeforeTax,
                MonthlyMortgageContribution = loanRequest.FinancialDetails.MonthlyMortgageContribution,
                MonthlyRentContribution     = loanRequest.FinancialDetails.MonthlyRentContribution,
                LoanReason                  = loanRequest.LoanReason.Reason,
                //EmploymentStatus = loanRequest.FinancialDetails.Employment.EmploymentStatus,
                UserId = userId
            });

            //Implement Service to generate a ref number
            var quote = "Test";

            return(Ok(new { LoanRed = quote }));
        }
Exemplo n.º 20
0
 public IActionResult Post([FromBody] CreateTextModule model)
 {
     model.SiteId = SiteId;
     model.Id     = Guid.NewGuid();
     _commandSender.Send <CreateTextModule, TextModule>(model);
     return(Ok(string.Empty));
 }
Exemplo n.º 21
0
        public IHttpActionResult Post(UserDetails userDetails)
        {
            var userId = Guid.NewGuid();
            var loanId = Guid.NewGuid();

            //Create User
            _command.Send(new UserRegister()
            {
                UserId      = userId,
                Firstname   = userDetails.Firstname,
                Lastname    = userDetails.Lastname,
                DoB         = userDetails.DoB,
                Title       = userDetails.Title,
                Email       = userDetails.Email,
                PhoneNumber = userDetails.PhoneNumber
            });

            //Add loan
            _command.Send(new ApplyForLoan()
            {
                UserId         = userId,
                LoanId         = loanId,
                APR            = userDetails.APR,
                LoanAmount     = userDetails.LoanAmount,
                MonthlyPayment = userDetails.MonthlyPayment,
                Years          = userDetails.Years
            });

            return(Ok());
        }
Exemplo n.º 22
0
        public ActionResult Add(string name)
        {
            var id = Guid.NewGuid();

            _commandSender.Send(new CreateInventoryItem(id, name));
            return(RedirectToAction("Details", new { id = id }));
        }
Exemplo n.º 23
0
        public async Task <IHttpActionResult> Post(
            [FromBody] PrintJob newPrintJob,
            [FromHeader] Guid clientRequestId,
            [RequestChecksum] string idempotencyToken,
            ODataQueryOptions <PrintJob> options,
            CancellationToken cancellationToken)
        {
            var thumbprint = certificateLocator.LocateByAccount(User).Thumbprint;
            var builder    = new PrintJobBuilder().ForCatalogItem(newPrintJob.CatalogId)
                             .WithQuantity(newPrintJob.Quantity)
                             .WithCertificateThumbprint(thumbprint)
                             .CorrelatedBy(clientRequestId.ToString())
                             .HasIdempotencyToken(idempotencyToken);

            using (var circuitBreaker = this.NewCircuitBreaker(cancellationToken))
            {
                builder.ForBillingAccount(await accounts.FindBusinessAccount(User, circuitBreaker.Token));

                var print = builder.NewPrint();

                await bus.Send(print, circuitBreaker.Token);

                newPrintJob.Id = print.AggregateId;
                newPrintJob.BillingAccountId = print.BillingAccountId;

                return(await circuitBreaker.CreatedOrAccepted(newPrintJob, ct => repository.GetSingleAsync(t => t.Id == newPrintJob.Id, ct)));
            }
        }
Exemplo n.º 24
0
        public async Task StripeConnectTransfersControllerApi()
        {
            _logger.Log(LogCategory.Debug, "Starting job");
            try
            {
                //start job here.
                var currenyList = await _querySender.Send(new CurrencyTypesQuery { });

                var queryResults = await _querySender.Send(new TransactionStripeConnectTransfersQuery { TransferDate = DateTime.Today });

                foreach (TransactionStripeConnectTransfer transactionStripeConnectTransfer in queryResults.transactionStripeConnectTransfers)
                {
                    var currency = currenyList.currencyTypes.Where(x => x.Id == transactionStripeConnectTransfer.CurrencyId).First().Code;
                    if (currency.ToUpper() == "AUD" || currency.ToUpper() == "USD")
                    {
                        _logger.Log(LogCategory.Debug, "starting transfer for " + transactionStripeConnectTransfer.Id.ToString());
                        // Create a PaymentIntent:
                        Transfer transfer = new Transfer();
                        try
                        {
                            var transferService = new TransferService();
                            var transferOption  = new TransferCreateOptions
                            {
                                Amount            = (long)(transactionStripeConnectTransfer.Amount),
                                Currency          = currenyList.currencyTypes.Where(x => x.Id == transactionStripeConnectTransfer.CurrencyId).First().Code,
                                Destination       = transactionStripeConnectTransfer.StripeConnectedAccount,
                                SourceTransaction = transactionStripeConnectTransfer.SourceTransactionChargeId
                            };

                            var apiKey = _settings.GetConfigSetting(FIL.Configuration.Utilities.SettingKeys.PaymentGateway.Stripe.SecretKey).Value;
                            if (currency.ToUpper() == "AUD")
                            {
                                apiKey = _settings.GetConfigSetting(FIL.Configuration.Utilities.SettingKeys.PaymentGateway.Stripe.FeelAustralia.SecretKey).Value;
                            }
                            transfer = transferService.Create(transferOption, new RequestOptions
                            {
                                ApiKey = apiKey
                            });
                            _logger.Log(LogCategory.Debug, "transfer completed for " + transactionStripeConnectTransfer.Id.ToString());
                            await _commandSender.Send <TransactionStripeConnectTransfersCommand>(new TransactionStripeConnectTransfersCommand { Id = transactionStripeConnectTransfer.Id, TransferApiResponse = transfer.ToString(), TransferDateActual = DateTime.Today });
                        }
                        catch (Exception ex)
                        {
                            _logger.Log(LogCategory.Error, ex);
                            await _commandSender.Send <TransactionStripeConnectTransfersCommand>(new TransactionStripeConnectTransfersCommand { Id = transactionStripeConnectTransfer.Id, TransferApiResponse = ex.ToString(), TransferDateActual = DateTime.Today });
                        }
                    }
                    else
                    {
                        await _commandSender.Send <TransactionStripeConnectTransfersCommand>(new TransactionStripeConnectTransfersCommand { Id = transactionStripeConnectTransfer.Id, TransferApiResponse = "cross region account.", TransferDateActual = DateTime.Today });
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(LogCategory.Error, ex);
            }
            _logger.Log(LogCategory.Debug, "Finishing Job.");
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Post([FromBody] CreateTextModule model)
        {
            model.SiteId = SiteId;
            model.Id     = Guid.NewGuid();
            await Task.Run(() => _commandSender.Send <CreateTextModule, TextModule>(model));

            return(Ok(string.Empty));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> Create(CreateLocationRequest request, CancellationToken ct = default)
        {
            var command = await _mapper.Map <CreateLocationCommand>(request);

            await _commandSender.Send(command, ct);

            return(Ok());
        }
Exemplo n.º 27
0
        public async Task <IActionResult> Save(CreateEmailAccount model)
        {
            model.SiteId = SiteId;
            model.Id     = Guid.NewGuid();
            await Task.Run(() => _commandSender.Send <CreateEmailAccount, EmailAccount>(model));

            return(new NoContentResult());
        }
        public async Task <IActionResult> CreateGame()
        {
            var gameId = Guid.NewGuid();
            var cmd    = new CreateGame(gameId, 10);
            await _bus.Send(cmd);

            return(new RedirectToActionResult("Get", "Games", new { gameId }));
        }
Exemplo n.º 29
0
        public async Task <IActionResult> Register([FromBody] RegisterUserRequestDto registerUserDto, CancellationToken cancellationToken)
        {
            var userId            = Guid.NewGuid();
            var createUserCommand = new RegisterUserCommand(userId, registerUserDto.FirstName, registerUserDto.LastName, registerUserDto.Email);
            await _commandSender.Send(createUserCommand, cancellationToken);

            return(Created(string.Empty, userId));
        }
Exemplo n.º 30
0
        public async Task <DescriptionResponseViewModel> SaveDescription([FromBody] DescriptionInputViewModel model)
        {
            var session = await _sessionProvider.Get();

            try
            {
                if (!model.IsStateDescription)
                {
                    var queryResult = await _querySender.Send(new DescriptionQuery
                    {
                        IsCountryDescription = model.IsCountryDescription,
                        Name = model.Name,
                        IsCityDescription  = model.IsCityDescription,
                        IsStateDescription = model.IsStateDescription,
                        StateId            = model.StateId
                    });


                    DescriptionCommandResult EventData = await _commandSender.Send <DescriptionCommand, DescriptionCommandResult>(new DescriptionCommand
                    {
                        CreatedBy            = session.User.AltId,
                        Description          = model.Description,
                        IsCountryDescription = model.IsCountryDescription,
                        IsStateDescription   = model.IsStateDescription,
                        IsCityDescription    = model.IsCityDescription,
                        Name    = model.Name,
                        City    = queryResult.City,
                        Country = queryResult.Country
                    });
                }
                else
                {
                    DescriptionCommandResult EventData = await _commandSender.Send <DescriptionCommand, DescriptionCommandResult>(new DescriptionCommand
                    {
                        CreatedBy            = session.User.AltId,
                        Description          = model.Description,
                        IsCountryDescription = model.IsCountryDescription,
                        IsStateDescription   = model.IsStateDescription,
                        IsCityDescription    = model.IsCityDescription,
                        Name    = model.Name,
                        StateId = model.StateId
                    });
                }


                return(new DescriptionResponseViewModel
                {
                    Success = true
                });
            }
            catch (Exception ex)
            {
                return(new DescriptionResponseViewModel
                {
                    Success = false
                });
            }
        }
 public FileDepositModule(ICommandSender sender)
 {
     Get["/deposit"] = _ =>
                    {
                        sender.Send(new FileDeposit());
                        return "File Deposit Made";
                    };
 }
Exemplo n.º 32
0
        public BusManagerModule(IRequeueAndRemove requeueAndRemove, IModelCreator modelCreator, ICommandSender commandSender)
            : base("/api/v1/busmanager")
        {
            _requeueAndRemove = requeueAndRemove;
            _modelCreator = modelCreator;
            _commandSender = commandSender;

            Get["/"] =
                _ => _modelCreator.Build<Overview>();
            Post["/deleteall"] =
                _ => {
                    _commandSender.Send(new DeleteAllBusEntititesCommand());
                    return new { success = true };
                };
            Get["/topic/{tid}"] =
                _ => _modelCreator.Build<Topic, TopicCriteria>(new TopicCriteria(To.String((object)_.tid)));
            Get["/queue/{qid}"] =
                _ => _modelCreator.Build<Queue, QueueCriteria>(new QueueCriteria(To.String((object)_.qid)));
            Get["/topic/{tid}/{sid}"] =
                _ => _modelCreator.Build<Subscription, SubscriptionCriteria>(new SubscriptionCriteria(To.String((object)_.tid), To.String((object)_.sid), true));
            Get["queue/{qid}/messages/{count}"] =
                _ => _modelCreator.Build<MessageView, FindQueuedMessages>(new FindQueuedMessages(To.String((object)_.qid).UnescapePathName(), To.Int(_.count)));
            Get["topic/{tid}/{sid}/messages/{count}"] =
                _ => _modelCreator.Build<MessageView, FindSubscriptionMessages>(new FindSubscriptionMessages(To.String((object)_.tid), To.String((object)_.sid).UnescapePathName(), To.Int(_.count)));
            Post["/queue/{qid}/requeue/all"] = _ =>
            {
                var qid = To.String((object)_.qid).UnescapePathName();
                _requeueAndRemove.RequeueAll(qid);
                return _modelCreator.Build<Queue, QueueCriteria>(new QueueCriteria(qid.RemoveDeadLetterPath(), true));
            };
            Post["/topic/{tid}/{sid}/requeue/all"] = _ =>
            {
                var tid = To.String((object)_.tid);
                var sid = To.String((object)_.sid).UnescapePathName();
                _requeueAndRemove.RequeueAll(tid, sid);
                return _modelCreator.Build<Subscription, SubscriptionCriteria>(new SubscriptionCriteria(tid, sid.RemoveDeadLetterPath(), true));
            };
            Post["/queue/{qid}/remove/all"] = _ =>
            {
                var qid = To.String((object)_.qid).UnescapePathName();
                _requeueAndRemove.RemoveAll(qid);
                return _modelCreator.Build<Queue, QueueCriteria>(new QueueCriteria(qid.RemoveDeadLetterPath(), true));
            };
            Post["/topic/{tid}/{sid}/remove/all"] = _ =>
            {
                var tid = To.String((object)_.tid);
                var sid = To.String((object)_.sid).UnescapePathName();
                _requeueAndRemove.RemoveAll(tid, sid);
                return _modelCreator.Build<Subscription, SubscriptionCriteria>(new SubscriptionCriteria(tid, sid.RemoveDeadLetterPath(), true));
            };
            Post["queue/{qid}/delete"] =
                _ => {
                    _commandSender.Send(new DeleteQueueCommand(To.String((object)_.qid).UnescapePathName().RemoveDeadLetterPath()));
                    _commandSender.Send(new RefreshCachedOverviewCommand());
                    return new { success = true };
                };
            Post["topic/{tid}/delete"] =
                _ => {
                    _commandSender.Send(new DeleteTopicCommand(To.String((object)_.tid).UnescapePathName()));
                    _commandSender.Send(new RefreshCachedOverviewCommand());
                    return new { success = true };
                };
            Post["topic/{tid}/{sid}/delete"] =
                _ => {
                    _commandSender.Send(new DeleteSubscriptionCommand(To.String((object)_.tid).UnescapePathName(), To.String((object)_.sid).UnescapePathName().RemoveDeadLetterPath()));
                    _commandSender.Send(new RefreshCachedOverviewCommand());
                    return new { success = true };
                };
            Post["queue/{qid}/remove"] =
                _ => { _commandSender.Send(new RemoveMessageCommand(Request.Form.messageId, To.String((object)_.qid).UnescapePathName())); return new { success = true }; };
            Post["queue/{qid}/dead/{mid}"] =
                _ => { _commandSender.Send(new DeadLetterMessageCommand(To.String((object)_.mid), To.String((object)_.qid).UnescapePathName())); return new { success = true }; };
            Post["queue/{qid}/dead"] =
                _ =>
                {
                    _commandSender.Send(new DeadLetterAllMessagesCommand(To.String((object)_.qid).UnescapePathName()));
                    return _modelCreator.Build<Queue, QueueCriteria>(new QueueCriteria(To.String((object)_.qid).RemoveDeadLetterPath(), true));
                };
            Post["queue/{qid}/requeue"] =
                _ => { _commandSender.Send(new RequeueMessageCommand(Request.Form.messageId, To.String((object)_.qid).UnescapePathName())); return new { success = true }; };
            Post["queue/{qid}/requeueModified"] =
                _ => { _commandSender.Send(new RequeueMessageCommand(Request.Form.messageId, To.String((object)_.qid).UnescapePathName()) { NewBody = Request.Form.body}); return new { success = true }; };
            Post["topic/{tid}/{sid}/remove"] =
                _ => { _commandSender.Send(new RemoveMessageCommand(Request.Form.messageId, To.String((object)_.tid), To.String((object)_.sid).UnescapePathName())); return new { success = true }; };
            Post["topic/{tid}/{sid}/dead/{mid}"] =
                _ => { _commandSender.Send(new DeadLetterMessageCommand(To.String((object)_.mid), To.String((object)_.tid), To.String((object)_.sid).UnescapePathName())); return new { success = true }; };
            Post["topic/{tid}/{sid}/dead"] =
                _ =>
                {
                    _commandSender.Send(new DeadLetterAllMessagesCommand(To.String((object)_.tid), To.String((object)_.sid).UnescapePathName()));
                    return _modelCreator.Build<Subscription, SubscriptionCriteria>(new SubscriptionCriteria(To.String((object)_.tid), To.String((object)_.sid).UnescapePathName(), true));
                };
            Post["topic/{tid}/{sid}/requeue"] =
                _ => { _commandSender.Send(new RequeueMessageCommand(Request.Form.messageId,To.String( _.tid), To.String((object)_.sid).UnescapePathName())); return new { success = true }; };
            Post["topic/{tid}/{sid}/requeueModified"] =
                _ => { _commandSender.Send(new RequeueMessageCommand(Request.Form.messageId, To.String(_.tid), To.String((object)_.sid).UnescapePathName()) { NewBody = Request.Form.body }); return new { success = true }; };

            Post["queue/{qid}"] =
                _ => { _commandSender.Send(new SendMessageCommand(To.String((object)_.qid).UnescapePathName(), this.Bind<Message>())); return new { success = true }; };
            Post["topic/{tid}"] =
                _ => { _commandSender.Send(new PublishMessageCommand(To.String((object)_.tid).UnescapePathName(), this.Bind<Message>())); return new { success = true }; };
        }