Ejemplo n.º 1
0
 public IActionResult Create(WorkItem item)
 {
     RequestLoger.DoLog(Request.Method, HttpContext.Connection.LocalIpAddress.ToString(), string.Join("/", new[] { Request.Host, RouteData.Values["controller"], RouteData.Values["action"] }));
     if (item == null)
     {
         return(BadRequest());
     }
     WorkItems.Add(item);
     return(new NoContentResult());
 }
Ejemplo n.º 2
0
        public IActionResult Delete(string key)
        {
            Request.Method = "DELETE";
            RequestLoger.DoLog(Request.Method, HttpContext.Connection.LocalIpAddress.ToString(), string.Join("/", new[] { Request.Host, RouteData.Values["controller"], RouteData.Values["action"] }));
            var work = WorkItems.Find(key);

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

            WorkItems.Remove(key);
            return(new NoContentResult());
        }
Ejemplo n.º 3
0
        public IActionResult Update(string key, WorkItem item)
        {
            Request.Method = "PUT";
            RequestLoger.DoLog(Request.Method, HttpContext.Connection.LocalIpAddress.ToString(), string.Join("/", new[] { Request.Host, RouteData.Values["controller"], RouteData.Values["action"] }));
            if (item == null || item.Key != key)
            {
                return(BadRequest());
            }

            var work = WorkItems.Find(key);

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

            WorkItems.Update(item);
            return(new NoContentResult());
        }
Ejemplo n.º 4
0
 public IEnumerable <WorkItem> GetAll()
 {
     RequestLoger.DoLog(Request.Method, HttpContext.Connection.LocalIpAddress.ToString(), string.Join("/", new[] { Request.Host, RouteData.Values["controller"], RouteData.Values["action"] }));
     return(WorkItems.GetAll());
 }