Пример #1
0
        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");
            }
        }
Пример #2
0
 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);
     }
 }
Пример #3
0
        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");
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);
        }