Beispiel #1
0
        public ActionResult Put(int id, [FromBody] Toll value)
        {
            var toll = _context.Tolls.Find(id);

            if (toll != null)
            {
                try
                {
                    toll.date = value.date;
                    _context.SaveChanges();
                } catch (Exception e)
                {
                    return(new NotFoundObjectResult(new { success = false, message = "Error while updating!", errorMessage = e.Message }));
                }

                return(new OkObjectResult(new { success = true, message = "Toll updated" }));
            }
            else
            {
                return(new NotFoundObjectResult(new { success = false, message = "Toll not found with id", id = id }));
            }
        }
 public void Post([FromBody] Owner owner)
 {
     _context.Owners.Add(owner);
     _context.SaveChanges();
 }