Example #1
0
 public IActionResult Create([FromBody] CartMhe cartmhe)
 {
     if (cartmhe == null)
     {
         return(BadRequest());
     }
     repo.Add(cartmhe);
     return(CreatedAtRoute("GetCartMHE", new { id = cartmhe.CartMheid }, cartmhe));
 }
Example #2
0
        // Update an CartMHE
        public void Update(CartMhe cartmhe)
        {
            var cartmheToUpdate = _context.CartMhe.Single(o => o.CartMheid == cartmhe.CartMheid);

            if (cartmheToUpdate != null)
            {
                cartmheToUpdate.DeadBattery          = cartmhe.DeadBattery;
                cartmheToUpdate.BrokenWheels         = cartmhe.BrokenWheels;
                cartmheToUpdate.TurntableMalfunction = cartmhe.TurntableMalfunction;
                cartmheToUpdate.Other       = cartmhe.Other;
                cartmheToUpdate.CartMhedate = cartmhe.CartMhedate;
                _context.SaveChanges();
            }
        }
Example #3
0
        public IActionResult Update(int id, [FromBody] CartMhe cartmhe)
        {
            if (cartmhe == null || cartmhe.CartMheid != id)
            {
                return(BadRequest());
            }

            var cartmheItem = repo.Find(id);

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

            repo.Update(cartmhe);
            return(new NoContentResult());
        }
Example #4
0
 // Add an CartMHE
 public void Add(CartMhe cartmhe)
 {
     _context.CartMhe.Add(cartmhe);
     _context.SaveChanges();
 }