/// <summary> /// Create a user event /// </summary> /// <param name="userId">User Id</param> /// <param name="eventType">Event Type</param> /// <param name="reference">Reference</param> /// <param name="notes">Notes</param> public void RecordUserEvent(Guid userId, UserEventTypesEnum eventType, string notes = null, string reference = null) { MembershipUser user = Membership.GetUser(userId); string userName = (user != null) ? user.UserName : null; RecordUserEvent(userName, eventType, notes, reference); }
/// <summary> /// Create a user event with notes /// </summary> /// <param name="userName">user name to record event for</param> /// <param name="eventType">Event type based upon UserEventTypeCode</param> /// <param name="notes">notes</param> /// <param name="reference">Reference</param> public void RecordUserEvent(string userName, UserEventTypesEnum eventType, string notes = null, string reference = null) { MembershipUser user = null; if (string.IsNullOrEmpty(userName) == false) { user = Membership.GetUser(userName); } //Empty used for bad username case Guid? foundUserId = user != null ? (Guid?)user.ProviderUserKey : Guid.Empty; var userEvent = new UserEvent { UserId = foundUserId, UserEventType = new UserEventType { Code = eventType.GetCode() }, Reference = reference ?? userName, Notes = notes, }; userEventDao.Create(userEvent); }
public void ModifyUserStatusCreatesRelatedEventType(UserStatusEnum userStatus, UserEventTypesEnum expectedUserEvent) { // Arrange var userId = new Guid("00000000-0000-0000-0000-000000000001"); string expectedUserEventCode = expectedUserEvent.GetCode(); var mockUserEventDao = MockRepository.GenerateMock<IUserEventDao>(); mockUserEventDao.Expect(u => u.Create(Arg<UserEvent>.Matches(ue => ue.UserEventType.Code == expectedUserEventCode))); var userManager = new UserManager(); userManager.UserEventDao = mockUserEventDao; userManager.UserExtensionDao = MockRepository.GenerateStub<IUserExtensionDao>(); // Act userManager.ModifyUserSatus(userId, userStatus, "notes"); // Assert mockUserEventDao.VerifyAllExpectations(); }