public EvernoteModel(EvernoteEntity entity) { if (entity == null) { return; } this.ID = entity.Id.ToString(); this.Content = entity.Content; this.CreateUser = entity.CreateUser != null ? entity.CreateUser.Id : 0; this.Title = entity.Title; DisplayName = entity.CreateUser != null ? entity.CreateUser.OperatorName : string.Empty; }
public ActionResult AutoGenerate() { for (int i = 0; i < 20; i++) { var model = new EvernoteEntity() { Content = i.ToString(), Group = i.ToString(), Title = string.Format("第{0}个", i) }; model.CreateUser = WebCrm.Framework.DependencyResolver.Resolver<IUserInfoService>().FindByUserName("LISG"); model.SetId(ModelReposity.GenerateId()); ModelReposity.Save(model); } return new JsonResult() { Data = new { Success = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
static ModelReposity() { _models = new List <EvernoteEntity>(); for (int i = 0; i < 20; i++) { var model = new EvernoteEntity() { Content = i.ToString(), Group = i.ToString(), Title = string.Format("第{0}个", i) }; model.CreateUser = DependencyResolver.Resolver <IUserInfoService>().FindByUserName("LISG"); model.SetId(GenerateId()); _models.Add(model); } }
public static void Save(EvernoteEntity entity) { var model = FindById(entity.Id); if (model == null) { entity.SetId(GenerateId()); _models.Add(entity); } else { _models.Remove(model); _models.Add(entity); } }
static ModelReposity() { _models = new List<EvernoteEntity>(); for (int i = 0; i < 20; i++) { var model = new EvernoteEntity() { Content = i.ToString(), Group = i.ToString(), Title = string.Format("第{0}个", i) }; model.CreateUser = DependencyResolver.Resolver<IUserInfoService>().FindByUserName("LISG"); model.SetId(GenerateId()); _models.Add(model); } }