// return UserId public static Api.Result RegNewUser(string email, string password) { Api.Result result = new Api.Result(); using (YardalEntities db = new YardalEntities()) { // user existed? var query = db.Users.Where(u => u.Email.Equals(email)); if (query.Count() > 0) { result.ErrorCodes = new List<int>() { Api.ERROR_CODES.RegNewUser_EmailAlreadyExists }; } else { User newUser = new User() { Email = email, Password = password, CreationDateUtc = DateTime.UtcNow }; db.AddToUsers(newUser); db.SaveChanges(); result.ReturnedObj = newUser.UserId; } } return result; }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="creationDateUtc">Initial value of the CreationDateUtc property.</param> public static User CreateUser(global::System.Int32 userId, global::System.String email, global::System.String password, global::System.DateTime creationDateUtc) { User user = new User(); user.UserId = userId; user.Email = email; user.Password = password; user.CreationDateUtc = creationDateUtc; return user; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }