public Session CreateSession(User user) { Session session = new Session() { id_user = user.id, session_key = Guid.NewGuid().ToString(), expire = DateTime.Now }; db.Sessions.InsertOnSubmit(session); db.SubmitChanges(); return GetSession(session.session_key); }
partial void DeleteUser(User instance);
partial void UpdateUser(User instance);
partial void InsertUser(User instance);
public WebResult Register(string username, string email, string password) { WebResult result = new WebResult(); var users = from u in db.Users where u.username == username || u.email == email select u; if (username == "" || password == "" || email == "") result.ErrorCode = WebResult.ErrorCodeList.INFORMATION_REQUIRED; else if (users.Count() > 0) result.ErrorCode = WebResult.ErrorCodeList.USER_ALREADY_EXIST; if (result.ErrorCode != WebResult.ErrorCodeList.SUCCESS) return result; User user = new User() { username = username, email = email, password = password }; db.Users.InsertOnSubmit(user); db.SubmitChanges(); return result; }
public AccountData(User user) { Id = user.id; Username = user.username; Password = user.password; IsSuperUser = user.superuser; }