示例#1
0
        /// <summary>
        /// 添加购物车
        /// </summary>
        /// <param name="OpenId">用户主键</param>
        /// <param name="Menu_Id"></param>
        /// <returns></returns>
        public int AddCar(string OpenId, int Menu_Id)
        {
            tb_Menu model = menuList.Where(s => s.M_Id == Menu_Id).FirstOrDefault();
            //获取该用户的购物车缓存
            List <tb_Menu> _menuList = _client.Get <List <tb_Menu> >(OpenId);

            if (_menuList != null)
            {
                tb_Menu m = _menuList.Where(s => s.M_Id == Menu_Id).FirstOrDefault();
                if (m != null)
                {
                    model.CarNum += 1;
                }
                else
                {
                    model.CarNum = 1;
                    _menuList.Add(model);
                }
            }
            else
            {
                _menuList    = new List <tb_Menu>();
                model.CarNum = 1;
                _menuList.Add(model);
            }
            _client.Set(OpenId, _menuList);
            return(_menuList.Count);
        }
示例#2
0
        /// <summary>
        /// 添加菜品
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddMenu(tb_Menu model)
        {
            string procName = "AddMenu";

            MySqlParameter[] mySqlParameters = new MySqlParameter[] {
                new MySqlParameter {
                    ParameterName = "MName", MySqlDbType = MySqlDbType.String, Direction = ParameterDirection.Input, Value = model.M_Name
                },
                new MySqlParameter {
                    ParameterName = "MImg", MySqlDbType = MySqlDbType.String, Direction = ParameterDirection.Input, Value = model.M_Img
                },
                new MySqlParameter {
                    ParameterName = "MPrice", MySqlDbType = MySqlDbType.Decimal, Direction = ParameterDirection.Input, Value = model.M_Price
                },
                new MySqlParameter {
                    ParameterName = "MMsale", MySqlDbType = MySqlDbType.Int32, Direction = ParameterDirection.Input, Value = model.M_Msale
                },
                new MySqlParameter {
                    ParameterName = "MDescription", MySqlDbType = MySqlDbType.String, Direction = ParameterDirection.Input, Value = model.M_Description
                },
                new MySqlParameter {
                    ParameterName = "MType", MySqlDbType = MySqlDbType.Int32, Direction = ParameterDirection.Input, Value = model.M_Type
                }
            };
            return(_dbHelper.ExecuteNonQuery_Proc(procName, mySqlParameters));
        }
示例#3
0
        public tb_Menu GetOneMenu(int MenuId)
        {
            List <tb_Menu> list  = GetAllMenu();
            tb_Menu        model = list.Where(s => s.M_Id == MenuId).FirstOrDefault();

            return(model);
        }
示例#4
0
        public async Task <ServiceResponse> UpdateEntity(tb_Menu entity)
        {
            byte[] bytes = await Server.UpdateEntityByMenuAsync(ZipTools.CompressionObject(entity));

            ServiceResponse response = ZipTools.DecompressionObject(bytes) as ServiceResponse;

            return(response);
        }
示例#5
0
        public async Task <ServiceResponse> GetModels(tb_Menu search)
        {
            var bytes = await Server.GetModelsByMenuAsync(ZipTools.CompressionObject(search));

            ServiceResponse response = ZipTools.DecompressionObject(bytes) as ServiceResponse;

            return(response);
        }
示例#6
0
        public async Task <ServiceResponse> GetPagingModels(int pageIndex, int pageSize, tb_Menu search, bool Asc = false)
        {
            var bytes = await Server.GetPagingModelsByMenuAsync(pageIndex, pageSize, ZipTools.CompressionObject(search), Asc);

            ServiceResponse response = ZipTools.DecompressionObject(bytes) as ServiceResponse;

            return(response);
        }
示例#7
0
 public int AddMenu([FromForm] tb_Menu model)
 {
     return(_menuBLL.AddMenu(model));
 }