예제 #1
0
        public IHttpActionResult getFoodItemByName(getFoodItemByCategoryObj obj)
        {
            try
            {
                if (obj.name == null)
                {
                    throw new Exception("name not set");
                }
                Food_Items result = foodItemObj.getItemByName(obj.name);
                if (result == null)
                {
                    return(Content(HttpStatusCode.NoContent, "No content found under this name"));
                }

                resObj.Status  = HttpStatusCode.OK;
                resObj.Data    = result;
                resObj.Message = "Content found";

                return(Ok(resObj));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.BadRequest, "Some error has occured. Error message : " + e.Message));
            }
        }
예제 #2
0
        public IHttpActionResult getFoodItemsByCategory(getFoodItemByCategoryObj obj)
        {
            try
            {
                if (obj.name == null)
                {
                    throw new Exception("name not set");
                }
                List <Food_Items> result = foodItemObj.getByCategory(obj.name).ToList();
                if (result.Count == 0)
                {
                    return(Content(HttpStatusCode.NoContent, "No content found under this category"));
                }

                resList.Status    = HttpStatusCode.OK;
                resList.Data      = result;
                resList.DataCount = result.Count;
                resList.Message   = "Content found";

                return(Ok(resList));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.BadRequest, "Some error has occured. Error message : " + e.Message));
            }
        }