public async Task <CommitteeUser> UpdateCommitteUserAsync(CommitteeUser user) { _context.CommitteeUsers.Update(user); await _context.SaveChangesAsync(); return(user); }
public CommitteeUser GetCommitteeUserData() { UserProfile userProfile = new UserProfile(1, "username", "fullname", phone, email, new List <UserNotificationSetting>()); CommitteeUser generalCommittee = new CommitteeUser(1, 1, 1, _agencyCode); generalCommittee.Test_AddUserProfile(userProfile); return(generalCommittee); }
public void Should_Construct_CommitteeUser() { var committeeUser = new CommitteeUser(CommitteeId, UserProfileId, UserRoleId); committeeUser.ShouldNotBeNull(); committeeUser.CommitteeId.ShouldBe(CommitteeId); committeeUser.UserProfileId.ShouldBe(UserProfileId); committeeUser.UserRoleId.ShouldBe(UserRoleId); }
public void Should_DeActive_CommitteeUser() { var committeeUser = new CommitteeUser(CommitteeId, UserProfileId, UserRoleId, RelatedAgencyCode); committeeUser.DeActive(); committeeUser.ShouldNotBeNull(); committeeUser.IsActive.ShouldNotBeNull(); committeeUser.IsActive.Value.ShouldBeFalse(); }
public void Should_Construct_CommitteeUser_With_AgencyCode() { var committeeUser = new CommitteeUser(CommitteeId, UserProfileId, UserRoleId, RelatedAgencyCode); committeeUser.ShouldNotBeNull(); committeeUser.CommitteeId.ShouldBe(CommitteeId); committeeUser.UserProfileId.ShouldBe(UserProfileId); committeeUser.UserRoleId.ShouldBe(UserRoleId); committeeUser.RelatedAgencyCode.ShouldBe(RelatedAgencyCode); }
public CommitteeUser GetCommitteeUserDataForUserProfile() { UserProfile userProfile = new UserProfile(1, "username", "fullname", "phone", "email", new List <UserNotificationSetting>()); CommitteeUser generalCommittee = new CommitteeUser(1, 1, 1, _agencyCode); generalCommittee.Test_AddCommittee(new Committee(1, _agencyCode, "committeeName", "address", "0533286913", "fax", "*****@*****.**", "11", "11", true)); generalCommittee.Test_AddUserProfile(userProfile); generalCommittee.CreateUserRoleForTest(); return(generalCommittee); }
public async Task AddUserAsyn(CommitteeUserModel committeeUserModel, string agencyCode) { Check.ArgumentNotNull(nameof(committeeUserModel), committeeUserModel); var user = await _iDMAppService.FindUserProfileByUserNameAsync(committeeUserModel.UserName); List <IDMRolesModel> roles = _iDMAppService.GetIDMRoles(); IDMRolesModel iDMRolesModel = roles.FirstOrDefault(r => r.Name == committeeUserModel.RoleName); Enums.UserRole userType = (Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), iDMRolesModel.Name, true); UserProfile userProfile = new UserProfile(); if (user == null) { userProfile = await _iDMAppService.GetUserProfileByEmployeeId(committeeUserModel.UserName, agencyCode, userType); Check.ArgumentNotNull(nameof(userProfile), userProfile); await _committeeDomainService.CheckUserExist(userProfile.Id, committeeUserModel.CommitteeId); await _genericCommandRepository.CreateAsync(userProfile); committeeUserModel.UserId = userProfile.Id; } else { var defaultSettingsForUserType = await _notificationAppService.GetDefaultSettingByUserType(userType); if (user.NotificationSetting.Count(x => x.UserRoleId == (int)userType) < defaultSettingsForUserType.Count) { await _committeeDomainService.CheckUserExist(user.Id, committeeUserModel.CommitteeId); user.AddNotificationSettings(defaultSettingsForUserType); _genericCommandRepository.Update(user); } committeeUserModel.UserId = user.Id; } CommitteeUser committeeUser = new CommitteeUser(committeeUserModel.CommitteeId, committeeUserModel.UserId, (int)((Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), iDMRolesModel.Name)), committeeUserModel.RelatedAgencyCode); await _genericCommandRepository.CreateAsync(committeeUser); await _genericCommandRepository.SaveAsync(); if (user != null) { if (!string.IsNullOrEmpty(user.Email) || !string.IsNullOrEmpty(user.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(user.Id, user.Email, user.Mobile); } } else { if (!string.IsNullOrEmpty(userProfile.Email) || !string.IsNullOrEmpty(userProfile.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(userProfile.Id, userProfile.Email, userProfile.Mobile); } } }
public void Should_Empty_Construct_CommitteeUser() { var committeeUser = new CommitteeUser(); committeeUser.ShouldNotBeNull(); committeeUser.CommitteeUserId.ShouldBe(0); committeeUser.RoleName.ShouldBeNullOrEmpty(); committeeUser.UserRole.ShouldBeNull(); committeeUser.UserProfile.ShouldBeNull(); committeeUser.Committee.ShouldBeNull(); }