Ejemplo n.º 1
0
        public async Task <Candidate> Create(Candidate candidate)
        {
            var result = await _context.Candidate.AddAsync(candidate);

            await _context.SaveChangesAsync();

            return(result.Entity);;
        }
        public async Task <ActionResult> PutCandidate(int id, Candidate candidate)
        {
            // if (id != candidate.id) return BadRequest();
            candidate.id = id;

            _context.Entry(candidate).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
                // if (!Candi)
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
 public async Task Create(Candidate candidate)
 {
     _context.Add(candidate);
     await _context.SaveChangesAsync();
 }