Exemple #1
0
        public async Task <IActionResult> PutTbDonation(int id, TbDonation tbDonation)
        {
            DateTime actual = DateTime.Now;

            tbDonation.DateUpdatedDonation = actual;

            if (id != tbDonation.IdDonation)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <ActionResult <TbDonation> > PostTbDonation(TbDonation tbDonation)
        {
            DateTime actual = DateTime.Now;

            tbDonation.DateCreatedDonation = actual;

            _context.TbDonations.Add(tbDonation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTbDonation", new { id = tbDonation.IdDonation }, tbDonation));
        }