示例#1
0
        public async void ModifyPurchase()
        {
            var command = new ModifyPurchaseCommand()
            {
                Cost         = 100,
                Currency     = "Ars",
                Participants = new[] { 1 },
            };

            HttpResponseMessage response = await _client.PutObjectAsync(PurchasesUrl + "/1", command);

            response.EnsureSuccessStatusCode();
            PurchaseModel purchase = await response.DeserializeObject <PurchaseModel>();

            Assert.Equal(1, purchase.Id);
            Assert.Equal(100U, purchase.Cost);
            Assert.Equal("Ars", purchase.Currency);
        }
        public async Task <ActionResult <IEnumerable <PurchaseModel> > > ModifyPurchase(int id, [FromBody] ModifyPurchaseCommand command)
        {
            if (command == null)
            {
                return(BadRequest("Datos invalidos"));
            }
            command.PurchaseId = id;
            PurchaseModel purchase = await Mediator.Send(command);

            return(Ok(purchase));
        }