Exemple #1
0
        public async Task <IActionResult> PutPaise(int id, Paise paise)
        {
            if (id != paise.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <ActionResult <Paise> > PostPaise(Paise paise)
        {
            _context.Paises.Add(paise);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPaise", new { id = paise.Id }, paise));
        }
        public void Create(PaisViewModel obj)
        {
            var entity = new Paise();

            entity.Nombre        = obj.Nombre;
            entity.Fechacreacion = DateTime.Now;
            entity.Codigo        = obj.Codigo;

            entities.Add(entity);
            entities.SaveChanges();
            obj.Id = entity.Id;
        }