public Entitys.WeUser CreateUser(WeUser user) { try { return(Insert(user)); } catch (Exception e) { return(null); } }
public void Save(WeUser user) { if (user == null) { return; } DataRow row = NewRow(); user.AddToDataRow(row); SetCommands(AdapterCommand.Insert); }
public static void CreateUser(string userId) { var newuser = new WeUser(); var alluser = (from temp in db.WeUsers select temp); if (alluser.Count() == 0) { newuser.Role = "Admin"; } else { newuser.Role = "User"; } newuser.SystemUserId = userId; db.WeUsers.Add(newuser); db.SaveChanges(); }
public static void ProcessNormalUser(bool subscrible, string openId) { using (EmptyDbDataSource source = WeDataUtil.CreateSource()) using (UserResolver resolver = new UserResolver(source)) using (SubscribeDataResolver subResolver = new SubscribeDataResolver(source)) { subResolver.SetCommands(AdapterCommand.Insert); resolver.SetCommands(AdapterCommand.Insert | AdapterCommand.Update); DateTime current = DateTime.Now; DataRow row = resolver.TrySelectRowWithKeys(openId); if (row == null) { row = resolver.NewRow(); } if (subscrible) { WeUser user = WeUser.GetUser(openId); user.AddToDataRow(row); } else { row["Subscribe"] = 0; } DataRow subRow = subResolver.NewRow(); subRow.BeginEdit(); subRow["Id"] = subResolver.CreateUniId(); subRow["OpenId"] = openId; subRow["SubscribeDate"] = current; subRow["IsSubscribe"] = subscrible ? 1 : 0; subRow.EndEdit(); UpdateUtil.UpdateTableResolvers(source.Context, null, new TableResolver[] { resolver, subResolver }); } }