public static string Update(int platenum, string meal, DateTime date, int id) { var result = string.Empty; try { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectToDb.Con("FeedMeDaily"))) { List <FoodModel> foods = new List <FoodModel>(); FoodModel foodModel = new FoodModel() { Date = date, PlateNum = platenum, Meal = meal }; foods.Add(foodModel); connection.Execute("spUpdatedb @id, @meal,@platenum,@date", foods); return(result = "successfulll"); } } catch (Exception ex) { var Err = ex.Message; return(result = "Failed"); } }
public static string GetFoodHistoryByID(int id) { try { var result = string.Empty; using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectToDb.Con("FeedMeDaily"))) { FoodModel food = new FoodModel(); result = connection.Query <FoodModel>("spGetDataid @id").ToString(); return(result); } } catch (Exception ex) { var Err = ex.Message; return(Err); } }
public static string Delete(int platenum, string meal, DateTime date, int id) { var result = string.Empty; try { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectToDb.Con("FeedMeDaily"))) { connection.Execute("spDeletedb"); return(result = "successfulll"); } } catch (Exception ex) { var Err = ex.Message; return(result = "Failed"); } }
public static List <FoodModel> FoodHistory() { var result = new List <FoodModel>(); try { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectToDb.Con("FeedMeDaily"))) { result = connection.Query <FoodModel>("spGetData").ToList(); return(result); } } catch (Exception ex) { var Err = ex.Message; return(result); } }
public static string Insert(int platenum, string meal, DateTime date) { var result = string.Empty; // DateTime date; try { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectToDb.Con("FeedMeDaily"))) { // food.Date = date; FoodModel food = new FoodModel() { Date = date, PlateNum = platenum, Meal = meal }; List <FoodModel> foods = new List <FoodModel>(); foods.Add(food); connection.Execute("spinsertfood @meal, @platenum, @date", foods); } result = "success"; } catch (Exception ex) { var err = ex.Message; result = "failed"; } return(result); }