예제 #1
0
        public async Task UpdateItemLeilao(ItensLeilao item)
        {
            if (db != null)
            {
                //Delete that post
                db.ItensLeilao.Update(item);

                //Commit the transaction
                await db.SaveChangesAsync();
            }
        }
예제 #2
0
        public async Task <int> AddItemLeilao(ItensLeilao item)
        {
            if (db != null)
            {
                await db.ItensLeilao.AddAsync(item);

                await db.SaveChangesAsync();

                return(item.Id);
            }

            return(0);
        }
        public void GetItensById_Return_OkResult()
        {
            // arrange
            ItensLeilao item = new ItensLeilao()
            {
                Id = 1
            };
            ItensLeilaoRepository repo = new ItensLeilaoRepository();

            // act
            var resultado = repo.GetItemLeilao(item.Id);

            //Assert
            Assert.Equal(resultado.Id, item.Id);
        }
        public async Task <IActionResult> PutItensLeilao(int id, ItensLeilao itensLeilao)
        {
            if (id != itensLeilao.Id)
            {
                return(BadRequest());
            }

            try
            {
                await _itensRepository.UpdateItemLeilao(itensLeilao);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(NoContent());
        }
        public async Task <ActionResult> PostItensLeilao(ItensLeilao itensLeilao)
        {
            await _itensRepository.AddItemLeilao(itensLeilao);

            return(CreatedAtAction("GetItensLeilao", new { id = itensLeilao.Id }, itensLeilao));
        }