public string GetCode(string Title)
        {
            var data   = KindCodeOperation.CodeData.Where(x => x.Title == Title).First();
            var result = DataMapperHelper.Map <CodeViewModel>(data);

            result.Kind = KindCodeOperation.Path_Kind(Title);
            return(JsonConvert.SerializeObject(result));
        }
Example #2
0
 /// <summary>
 /// 创建数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Create(TModel model)
 {
     try
     {
         TBmobModel Bmodel = DataMapperHelper.Map <TBmobModel>(model);
         var        future = Bmob.CreateTaskAsync(Bmodel);
         return(future.Result.objectId);
     }catch (Exception e)
     {
         return(null);
     }
 }
Example #3
0
 //修改字段
 public bool ModifyData(TModel model)
 {
     try
     {
         TBmobModel Bmodel = DataMapperHelper.Map <TBmobModel>(model);
         var        future = Bmob.UpdateTaskAsync <TBmobModel>(Bmodel);
         return(true);
     }
     catch (Exception e)
     {
         string message = e.Message;
         return(false);
     }
 }
Example #4
0
        //根据字段获取数据
        public IEnumerable <TModel> GetByNoId(string BmobTable, string Field, object Value)
        {
            var query = new BmobQuery();

            query.WhereEqualTo(Field, Value);
            var           future = Bmob.FindTaskAsync <TBmobModel>(BmobTable, query);
            List <TModel> model  = new List <TModel>();

            foreach (var data in future.Result.results)
            {
                model.Add(DataMapperHelper.Map <TModel>(data));
            }
            return(model);
        }
 /// <summary>
 /// 获取代码给app
 /// </summary>
 /// <param name="title"></param>
 /// <returns></returns>
 public string GetCode(string title)
 {
     try
     {
         var data = KindCodeOperation.CodeData.Where(x => x.Title == title).First();
         data.Code = HttpUtility.UrlDecode(data.Code);
         data.Code = data.Code.Replace(" ", "\\b");
         var result = DataMapperHelper.Map <CodeViewModel>(data);
         result.Kind = KindCodeOperation.Path_Kind(title);
         return(JsonConvert.SerializeObject(result));
     }
     catch (Exception e)
     {
         return("您提交的数据标题为:" + title + "\n" + e.Message);
     }
 }
Example #6
0
        //根据id获取单个数据
        public TModel GetById(string BmobTable, string ObjectId)
        {
            var future = Bmob.GetTaskAsync <TBmobModel>(BmobTable, ObjectId);

            return(DataMapperHelper.Map <TModel>(future.Result));
        }