//获取膳食所有数据
        public JsonResult getFoodInfoList()
        {
            var res = new JsonResult();

            BLL.Food    _food        = new BLL.Food();
            DataTable   dt           = _food.GetFoodInfoList();
            List <food> foodInfoList = new List <food>();

            if (dt.Rows.Count >= 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    food f = new food();
                    f.id             = dt.Rows[i]["id"].ToString();
                    f.type           = dt.Rows[i]["type"].ToString();
                    f.sub_type       = dt.Rows[i]["sub_type"].ToString();
                    f.title          = dt.Rows[i]["title"].ToString();
                    f.energy_kilocal = Convert.ToDouble(dt.Rows[i]["energy_kilocal"].ToString());
                    f.ca_mg          = Convert.ToDouble(dt.Rows[i]["ca_mg"].ToString());
                    f.protein_g      = Convert.ToDouble(dt.Rows[i]["protein_g"].ToString());
                    f.riboflavin_mg  = Convert.ToDouble(dt.Rows[i]["riboflavin_mg"].ToString());
                    f.mg_mg          = Convert.ToDouble(dt.Rows[i]["mg_mg"].ToString());
                    f.fat_g          = Convert.ToDouble(dt.Rows[i]["fat_g"].ToString());
                    f.niacin_mg      = Convert.ToDouble(dt.Rows[i]["niacin_mg"].ToString());
                    f.fe_mg          = Convert.ToDouble(dt.Rows[i]["fe_mg"].ToString());
                    f.vc_mg          = Convert.ToDouble(dt.Rows[i]["vc_mg"].ToString());
                    f.mn_mg          = Convert.ToDouble(dt.Rows[i]["mn_mg"].ToString());
                    f.ve_mg          = Convert.ToDouble(dt.Rows[i]["ve_mg"].ToString());
                    f.zn_mg          = Convert.ToDouble(dt.Rows[i]["zn_mg"].ToString());
                    f.cu_mg          = Convert.ToDouble(dt.Rows[i]["cu_mg"].ToString());
                    f.k_mg           = Convert.ToDouble(dt.Rows[i]["k_mg"].ToString());
                    f.p_mg           = Convert.ToDouble(dt.Rows[i]["p_mg"].ToString());
                    f.re_ug          = Convert.ToDouble(dt.Rows[i]["re_ug"].ToString());
                    f.na_mg          = Convert.ToDouble(dt.Rows[i]["na_mg"].ToString());
                    f.se_ug          = Convert.ToDouble(dt.Rows[i]["se_ug"].ToString());

                    foodInfoList.Add(f);
                }
                res.Data = new
                {
                    success  = true,
                    backData = foodInfoList
                };
            }
            else
            {
                res.Data = new
                {
                    success = false,
                    backMsg = "膳食查询失败"
                };
            }
            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。

            return(res);
        }
Beispiel #2
0
 //插入Food信息
 public bool Insert(Food food)
 {
     return(foodDAL.InsertOneRecord(food));
 }
Beispiel #3
0
        public Food GetFoodById(int?id)
        {
            Food food = ifood.GetFoodById(id);

            return(food);
        }