Exemplo n.º 1
0
        public async Task <IActionResult> PutAdotar(Guid id, Adotar adotar)
        {
            if (id != adotar.Id)
            {
                return(BadRequest());
            }

            _context.Entry(adotar).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AdotarExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,ClienteId,AnimalId,DataAdocao")] Adotar adotar)
        {
            if (id != adotar.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(adotar);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdotarExists(adotar.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(adotar));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Adotar> > PostAdotar(Adotar adotar)
        {
            //Utilizado antes de criar o CQRS
            //adotar.Id = Guid.NewGuid();
            //_context.Adocoes.Add(adotar);
            //await _context.SaveChangesAsync();

            await apiApplicationService.CreateAdotarAsync(adotar.ClienteId, adotar.AnimalId, adotar.DataAdocao);

            return(CreatedAtAction("GetAdotar", new { id = adotar.Id }, adotar));
        }
Exemplo n.º 4
0
        public async void Update(Adotar entity)
        {
            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Add("Authorization", "bearer " + token);

            var serializedAdotar = serializerService.Serialize(entity);
            var httpContent      = new StringContent(serializedAdotar, Encoding.UTF8, "application/json");

            await httpClient.PutAsync("https://petshop-adotarmicroservice-api-sergio.azurewebsites.net/api/Adotars", httpContent);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,ClienteId,AnimalId,DataAdocao")] Adotar adotar)
        {
            if (ModelState.IsValid)
            {
                adotar.Id = Guid.NewGuid();
                _context.Add(adotar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(adotar));
        }
Exemplo n.º 6
0
 public async Task AddAdotarAsync(string token, Adotar adotarViewModel)
 {
     var adotarRepository = new AdotarRepository(serializerService, token);
     var adotarService    = new AdotarService(adotarRepository);
     await adotarService.AddAdotarAsync(adotarViewModel);
 }
 public ProcessAdotarCommand(Adotar adotar) : base()
 {
 }
Exemplo n.º 8
0
 public AdotarCommand(Adotar adotar) : base()
 {
     Adotar = adotar;
 }