예제 #1
0
        public static Licence[] GetLicencesForUser(User user, bool loadTrackers)
        {
            // Create result variable
            Licence[] result = null;

            // Create licence query
            var trackerQuery = DataHandler.GetContext().Licence.Where(l => l.UserId == user.Id).Include(l => l.Tracker);

            // Run query
            if (trackerQuery.Any()) result = trackerQuery.ToArray();

            //Return result
            return result;
        }
예제 #2
0
 public static void CreateLicence(User currentUser, Tracker newTracker, DateTime dateTime)
 {
     Licence l = new Licence
         {
             UserId = currentUser.Id,
             TrackerId = newTracker.Id,
             CreationDate = DateTime.Now,
             ValidFrom = DateTime.Now,
             ValidUntil = dateTime,
             Id = Guid.NewGuid()
         };
     var context = DataHandler.GetContext();
     context.Licence.AddObject(l);
     context.SaveChanges();
 }
        public static MembershipUser GetMembershipUserFromCustomEntity(User user)
        {
            if (user == null) return null;

            return new MembershipUser(
                "CustomMembershipProvider",
                user.Name,
                user.Id,
                user.Email,
                string.Empty,
                user.Comments,
                true,
                user.IsLockedOut,
                user.CreationDate,
                user.LastLoginDate ?? user.CreationDate,
                DateTime.Now,
                DateTime.Now,
                user.LastLockedOutDate ?? user.CreationDate);
        }
예제 #4
0
        public static User CreateUser(string username, string password, string email, bool isApproved)
        {
            var context = DataHandler.GetContext();
            User user = new User
                {
                    Id = Guid.NewGuid(),
                    Name = username,
                    CreationDate = DateTime.Now,
                    LastModifiedDate = DateTime.Now,
                    LastLoginDate = DateTime.Now,
                    Password = PasswordHash.CreateHash(password),
                    Email = email,
                    IsActivated = true,
                    IsLockedOut = false
                };
            context.User.AddObject(user);
            context.SaveChanges();

            user = GetUser(user.Name);
            return user;
        }
예제 #5
0
 public void GetUser()
 {
     _testUser = null;
     _testUser = UserLogic.GetUser("Test");
     Assert.IsNotNull(_testUser);
 }
예제 #6
0
 public void CreateUser()
 {
     _testUser = UserLogic.CreateUser("Test", "test", "*****@*****.**", true);
     Assert.IsNotNull(_testUser);
 }
예제 #7
0
 public static void UpdateUser(User user)
 {
     DataHandler.GetContext().AcceptAllChanges();
 }
예제 #8
0
 partial void DeleteUser(User instance);
예제 #9
0
 partial void UpdateUser(User instance);
예제 #10
0
 partial void InsertUser(User instance);
예제 #11
0
 /// <summary>
 /// Deprecated Method for adding a new object to the User EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUser(User user)
 {
     base.AddObject("User", user);
 }
예제 #12
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="isActivated">Initial value of the IsActivated property.</param>
 /// <param name="isLockedOut">Initial value of the IsLockedOut property.</param>
 public static User CreateUser(global::System.Guid id, global::System.String name, global::System.DateTime creationDate, global::System.String password, global::System.Boolean isActivated, global::System.Boolean isLockedOut)
 {
     User user = new User();
     user.Id = id;
     user.Name = name;
     user.CreationDate = creationDate;
     user.Password = password;
     user.IsActivated = isActivated;
     user.IsLockedOut = isLockedOut;
     return user;
 }