public MainWindow()
 {
     foodDao = new FoodDAOMSSQL();
     InitializeComponent();
     foods            = foodDao.GetAllFoods();
     grid.ItemsSource = foods;
 }
Esempio n. 2
0
        public HttpResponseMessage Get([FromUri] int id)
        {
            FoodDAOMSSQL        foodDao = new FoodDAOMSSQL();
            Food                food    = foodDao.GetfoodById(id);
            HttpResponseMessage msg     = Request.CreateResponse(HttpStatusCode.OK, food);

            return(msg);
        }
Esempio n. 3
0
        public HttpResponseMessage Get()
        {
            List <Food>  foods   = new List <Food>();
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();

            foods = foodDao.GetAllFoods();
            HttpResponseMessage msg = Request.CreateResponse(HttpStatusCode.OK, foods);

            return(msg);
        }
Esempio n. 4
0
        public HttpResponseMessage GetByName(string name)
        {
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();
            List <Food>  foods   = foodDao.GetByFoodName(name);

            if (foods.Count == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, foods));
        }
Esempio n. 5
0
        public HttpResponseMessage Search(string name = "", int maxcal = 0, int mincal = 0, string ingridients = "", int grade = 0)
        {
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();
            List <Food>  foods   = foodDao.GetByFilter(name, maxcal, mincal, ingridients, grade);

            if (foods.Count == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, foods));
        }
Esempio n. 6
0
        public HttpResponseMessage BiggerThan(int calories)
        {
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();
            List <Food>  foods   = foodDao.GetFoodBiggerthanCal(calories);

            if (foods.Count == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, foods));
        }
Esempio n. 7
0
        public HttpResponseMessage Delete(int id)
        {
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();

            if (id == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            else
            {
                foodDao.DeleteFood(id);
                return(Request.CreateResponse(HttpStatusCode.OK, id));
            }
        }
Esempio n. 8
0
        public HttpResponseMessage Put(int id, Food f)
        {
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();

            if (f == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            else
            {
                foodDao.UpdateFood(id, f);
                return(Request.CreateResponse(HttpStatusCode.OK, f));
            }
        }
Esempio n. 9
0
        public HttpResponseMessage Post([FromBody] Food f)
        {
            FoodDAOMSSQL foodDao = new FoodDAOMSSQL();

            if (f == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            else
            {
                foodDao.AddFood(f);
                return(Request.CreateResponse(HttpStatusCode.Created, f));
            }
        }
Esempio n. 10
0
 public ViewAddFood()
 {
     foodDao = new FoodDAOMSSQL();
     InitializeComponent();
 }