Exemplo n.º 1
0
        public IActionResult Delete(int id)
        {
            Fidget_Spinner delete = _context.fidget_spinners.Where(c => c.fidget_id == id).FirstOrDefault();

            _context.fidget_spinners.Remove(delete);
            _context.SaveChanges();
            return(Ok(delete));
        }
Exemplo n.º 2
0
 public IActionResult Post([FromBody] Fidget_Spinner spinner)
 {
     if (spinner == null)
     {
         return(NotFound());
     }
     _context.fidget_spinners.Add(spinner);
     _context.SaveChanges();
     return(Ok(spinner));
 }
Exemplo n.º 3
0
        public ActionResult GetById(int id)
        {
            Fidget_Spinner spinner = _context.fidget_spinners.Where(c => c.fidget_id == id).FirstOrDefault();

            if (spinner == null)
            {
                return(NotFound());
            }
            return(Ok(spinner));
        }
Exemplo n.º 4
0
        public IActionResult Put(int id, [FromBody] Fidget_Spinner spinner)
        {
            Fidget_Spinner delete = _context.fidget_spinners.Where(c => c.fidget_id == id).FirstOrDefault();

            if (spinner == null || delete == null)
            {
                return(NotFound());
            }

            _context.fidget_spinners.Remove(delete);
            _context.fidget_spinners.Add(spinner);
            _context.SaveChanges();

            return(Ok(spinner));
        }