Exemplo n.º 1
0
        public async Task <IActionResult> PutDCandidate(int id, DCandidate dCandidate)
        {
            //if (id != dCandidate.id)
            //{
            //    return BadRequest();
            //}

            dCandidate.id = id;

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

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

            return(NoContent());
        }
        public async Task <DonationCandidate> Add(DonationCandidate donationCandidate)
        {
            await _donationDbContext.DonationCandidates.AddAsync(donationCandidate);

            await _donationDbContext.SaveChangesAsync();

            return(donationCandidate);
        }
Exemplo n.º 3
0
 public async Task <IActionResult> PutCandidate(int id, [FromBody] Candidate candidate)
 {
     candidate.Id = id;
     _dbContext.Entry(candidate).State = EntityState.Modified;
     try
     {
         await _dbContext.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         if (!DbCandidateExists(id))
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     return(NoContent());
 }
        public async Task <ActionResult> Update(long id, DonationCandidate donationCandidate)
        {
            donationCandidate.Id = id;

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await _context.DonationCandidates.AnyAsync(x => x.Id == id))
                {
                    return(NotFound());
                }

                // Logger to add.
                throw;
            }

            return(NoContent());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> PutDonationCandidate(int id, DonationCandidate donationCandidate)
        {
            donationCandidate.Id = id;

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

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

            return(NoContent());
        }
Exemplo n.º 6
0
 public async Task UpdateCandidateAsync(int id, DonationCandidate donationCandidate)
 {
     _context.Entry(donationCandidate).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }