Exemplo n.º 1
0
        public IActionResult DeleteBread(int id)
        {
            BreadInventory bread = _context.BreadInventory.SingleOrDefault(b => b.id == id);

            if (bread == null)
            {
                return(NotFound());
            }
            _context.Remove(bread);
            _context.SaveChanges();
            return(NoContent());
        }
Exemplo n.º 2
0
        public IActionResult SellBread(int id)
        {
            BreadInventory bread = _context.BreadInventory.SingleOrDefault(b => b.id == id);

            if (bread == null)
            {
                return(NotFound());
            }
            bread.sell();
            _context.Update(bread);
            _context.SaveChanges();
            return(Ok(bread));
        }
Exemplo n.º 3
0
        public IActionResult MakeBread([FromBody] BreadInventory bread)
        {
            Baker baker = _context.Bakers.SingleOrDefault(b => b.id == bread.bakedByid);

            if (baker == null)
            {
                // TODO: Add a validation error
                return(NotFound());
            }

            // bread.bakedBy will already have been populated, as long as bakedByid was valid!
            _context.Add(bread);
            _context.SaveChanges();
            return(Ok(bread)); // TODO: change this to CreatedAtAction
        }