Example #1
0
        public async Task <IActionResult> PurchaseAsync([FromBody] PurchaseDocumentRequest model, CancellationToken token)
        {
            var userId = _userManager.GetLongUserId(User);

            try
            {
                var command = new PurchaseDocumentCommand(model.Id, userId);
                await _commandBus.DispatchAsync(command, token);
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }
            catch (InsufficientFundException)
            {
                ModelState.AddModelError(string.Empty, _localizer["InSufficientFunds"]);
                return(BadRequest(ModelState));
            }
            catch (DuplicateRowException)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Example #2
0
        private static async Task RamMethod()
        {
            //ResourcesMaintenance.DeleteStuffFromJs();
            var s = Container.Resolve <ICommandBus>();

            try
            {
                var command = new PurchaseDocumentCommand(7491, 638);
                await s.DispatchAsync(command, default);
            }
            catch (DuplicateRowException)
            {
            }
            //var result = await s.GetPaymentAsync("4J34525079381873W", default);
            ////var x = await s.QueryAsync(new StudyRoomQuery(Guid.Parse("9f54280c-103e-46a6-8184-aabf00801beb"), 638), default);
        }