public MainWindow() { foodDao = new FoodDAOMSSQL(); InitializeComponent(); foods = foodDao.GetAllFoods(); grid.ItemsSource = foods; }
public HttpResponseMessage Get([FromUri] int id) { FoodDAOMSSQL foodDao = new FoodDAOMSSQL(); Food food = foodDao.GetfoodById(id); HttpResponseMessage msg = Request.CreateResponse(HttpStatusCode.OK, food); return(msg); }
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); }
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)); }
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)); }
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)); }
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)); } }
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)); } }
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)); } }
public ViewAddFood() { foodDao = new FoodDAOMSSQL(); InitializeComponent(); }