//// DELETE: api/VoteCompanies/5
        //[ResponseType(typeof(VoteCompany))]
        //public IHttpActionResult DeleteVoteCompany(int id)
        //{
        //    VoteCompany voteCompany = db.VoteCompanies.Find(id);
        //    if (voteCompany == null)
        //    {
        //        return NotFound();
        //    }

        //    db.VoteCompanies.Remove(voteCompany);
        //    db.SaveChanges();

        //    return Ok(voteCompany);
        //}

        private bool VoteCompanyExists(int id)
        {
            using (var db = new CompanyRatesAPIContext())
            {
                return(db.VoteCompanies.Count(e => e.VoteCompanyID == id) > 0);
            }
        }
Example #2
0
        public static void Register(HttpConfiguration config)
        {
            using (var db = new CompanyRatesAPIContext())
            {
                db.Database.CreateIfNotExists();
            }
            // Web API configuration and services
            //config.EnableCors(new EnableCorsAttribute("*", "*", "GET, POST, OPTIONS, PUT, DELETE"));
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            //config.Routes.MapHttpRoute(
            //    name: "ControllerAndAction",
            //    routeTemplate: "api/{controller}/{action}"
            //);

            config.Formatters.JsonFormatter.SupportedMediaTypes
            .Add(new MediaTypeHeaderValue("text/html"));
        }