Пример #1
0
 /// <summary>
 /// 修改数据。必须传入Id
 /// </summary>
 public BaseResult UptUser(TestTableParam param)
 {
     if (param.Id == null)
     {
         return new BaseResult(false, null, Msg.ParamError);
     }
     var model = new TestTable1();
     if (param.Name != null)
         model.Name = param.Name;
     if (param.IDNumber != null)
         model.IDNumber = param.IDNumber;
     if (param.MobilePhone != null)
         model.MobilePhone = param.MobilePhone;
     var count = TestTableRepository.Update(model, d => d.Id == param.Id);
     //更新缓存
     TestTableCache.DelUserModel(param.Id.Value);
     return new BaseResult(true);
 }
Пример #2
0
 /// <summary>
 /// 新增数据。必须传入姓名Name,手机号MobilePhone,身份证号IDNumber
 /// </summary>
 public BaseResult AddUser(TestTableParam param)
 {
     if (string.IsNullOrWhiteSpace(param.Name) || string.IsNullOrWhiteSpace(param.MobilePhone)
             || string.IsNullOrWhiteSpace(param.IDNumber))
     {
         return new BaseResult(false, null, Msg.ParamError);
     }
     var model = new TestTable1
     {
         Id = Guid.NewGuid(),
         Name = param.Name,
         IDNumber = param.IDNumber,
         MobilePhone = param.MobilePhone,
         CreateTime = DateTime.Now
     };
     var count = TestTableRepository.Insert(model);
     //设置缓存
     TestTableCache.SetUserModel(model);
     return new BaseResult(count > 0, count, count > 0 ? "" : Msg.Line0);
 }
Пример #3
0
 public static bool SetUserModel(TestTable1 model)
 {
     return Set("GetUser" + model.Id, model);
 }