Exemplo n.º 1
0
        public async Task <ActionResult <Mermas> > PostMermas(Mermas mermas)
        {
            _context.Mermas.Add(mermas);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMermas", new { id = mermas.IdMerma }, mermas));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutMermas(int id, Mermas mermas)
        {
            if (id != mermas.IdMerma)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Mermas> > GetMermas(int id)
        {
            Mermas mermas = await _context.Mermas.FindAsync(id);

            if (mermas == null)
            {
                return(NotFound());
            }

            return(mermas);
        }
Exemplo n.º 4
0
        public void Put(int id, [FromBody] Mermas newObj)
        {
            var oldObj = db.Mermas.Find(id);

            if (oldObj == null)
            {
                return;
            }
            newObj.Id = oldObj.Id;
            db.Entry(oldObj).CurrentValues.SetValues(newObj);
            db.SaveChanges();
        }
Exemplo n.º 5
0
        public async Task <ActionResult <Mermas> > DeleteMermas(int id)
        {
            Mermas mermas = await _context.Mermas.FindAsync(id);

            if (mermas == null)
            {
                return(NotFound());
            }

            _context.Mermas.Remove(mermas);
            await _context.SaveChangesAsync();

            return(mermas);
        }
Exemplo n.º 6
0
 public void Post(Mermas sync)
 {
     db.Mermas.Add(sync);
     db.SaveChanges();
 }