Esempio n. 1
0
        public IHttpActionResult GetPizzas()
        {
            try
            {
                Core.Core core   = new Core.Core();
                var       pizzas = core.GetPizzas();

                if (pizzas == null || !pizzas.Any())
                {
                    throw new NullReferenceException("No Pizzas Found");
                }

                return(Json(pizzas));
            }
            catch (NullReferenceException nex)
            {
                return(Content(HttpStatusCode.NotFound, new { Code = (int)HttpStatusCode.NotFound, Message = nex.Message }));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, new { Code = (int)HttpStatusCode.InternalServerError, Message = ex.Message }));
            }
        }