public IActionResult Delete(int id, bool isRestore = false)
 {
     if (isRestore)
     {
         _handler.Restore(id);
     }
     else
     {
         _handler.Delete(id);
     }
     return(NoContent());
 }
Exemplo n.º 2
0
        public IDictionary <string, string> HandleRequest(Request request, ICrudHandler handler)
        {
            IDictionary <string, string> response = new Dictionary <string, string>();

            if (request.Type == RequestType.Create)
            {
                handler.Create(request.EntityName, request.Arguments);
                response["result"] = "success";
            }

            if (request.Type == RequestType.Get)
            {
                IEnumerable foundObjects = handler.Read(request.EntityName, request.Arguments);
                var         objectArray  = "[";
                var         isFirst      = true;
                foreach (var nextObject in foundObjects)
                {
                    if (isFirst)
                    {
                        objectArray += nextObject;
                        isFirst      = false;
                    }
                    else
                    {
                        objectArray += "," + nextObject;
                    }
                }

                response["result"]   = "success";
                response["selected"] = objectArray + "]";
            }

            if (request.Type == RequestType.Update)
            {
                handler.Update(request.EntityName, request.Arguments);
                response["result"] = "success";
            }

            if (request.Type == RequestType.Delete)
            {
                handler.Delete(request.EntityName, request.Arguments);
            }

            if (request.Type == RequestType.Default)
            {
                response["result"]  = "failure";
                response["message"] = "Unknown request type";
            }

            return(response);
        }
Exemplo n.º 3
0
 public IActionResult Delete(int id)
 {
     _handler.Delete(id);
     return(NoContent());
 }