Esempio n. 1
0
        // POST api/<controller>
        public HttpResponseMessage Post([FromBody] carModel value)
        {
            if (value == null)
            {
                return(null);
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            carService          service  = new carService();
            HttpResponseMessage response = null;
            Object result = null;

            switch (value.method)
            {
            case "master":
                result = service.master(value);
                break;

            case "search":
                result = service.search(value);
                break;

            case "insert":
                result = service.insert(value);
                break;

            case "update":
                result = service.update(value);
                break;

            case "delete":
                result = service.delete(value);
                break;

            default:
                break;
            }


            string json = js.Serialize(result);

            response         = Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
            return(response);
        }
        public List <Car> GetAllCars()
        {
            carService carsService = new carService();

            return(carsService.GetAllCars());
        }