示例#1
0
		private void ChangeStatusOfAppraiserUsers(AppraisalCompanyDetail companyDetail, AppraisalCompanyStatus newStatus, AppraisalCompanyStatus oldStatus)
		{
			if (oldStatus == AppraisalCompanyStatus.Applied && newStatus == AppraisalCompanyStatus.Active)
				return;

			var userMapper = new CompanyUserMapper();
			var historyMapper = new CompanyStatusHistoryMapper();

			foreach (var appraiserUser in _appraiserManagement.GetUsersForCompany(companyDetail.Id))
			{
				if (appraiserUser.User.Roles.Any(e => e.RoleType != RoleType.Appraiser) || appraiserUser.Status == AppraiserUserStatus.Applied)
					continue;
				if (newStatus == AppraisalCompanyStatus.Suspended && appraiserUser.Status == AppraiserUserStatus.Inactive)
					continue;
                if ((newStatus == AppraisalCompanyStatus.Inactive || newStatus == AppraisalCompanyStatus.Suspended) && (appraiserUser.Status == AppraiserUserStatus.Applied))
                    continue;

				var appraiserUserStatus = userMapper.ToUserStatus(newStatus);
                
				if (newStatus == AppraisalCompanyStatus.Active)
				{
					var historyForCompany = _trackingRepository.GetAppraisalCompanyStatusHistory(companyDetail.Id).FirstOrDefault(e => e.OldValue == AppraisalCompanyStatus.Active.ToString());
					if (historyForCompany != null)
					{
						var history = _trackingRepository.GetAppraiserStatusHistory(appraiserUser.User.Id).ToArray();
						var lastHistory = history.FirstOrDefault(e => e.ChangeEntity.ChangeSet.Date == historyForCompany.ChangeEntity.ChangeSet.Date);

						if (lastHistory == null)
						{
							lastHistory = history.FirstOrDefault(e => e.ChangeEntity.ChangeSet.Date <= historyForCompany.ChangeEntity.ChangeSet.Date);
							if (lastHistory != null)
							{
								appraiserUserStatus = userMapper.ToUserStatus(historyMapper.Mapp(lastHistory.NewValue));
							}
						}
						else
						{
							appraiserUserStatus = userMapper.ToUserStatus(historyMapper.Mapp(lastHistory.OldValue));
						}
					}
				}

				appraiserUser.Status = appraiserUserStatus;
			}
		}
示例#2
0
		public void StatusChanged(AppraisalCompanyBranch companyBranch, AppraisalCompanyStatus newStatus,
															AppraisalCompanyStatus oldStatus)
		{
			var statusMapper = new CompanyUserMapper();
			var historyMapper = new CompanyStatusHistoryMapper();

			foreach (var appraiserUser in _appraiserManagement.GetUsersForBranch(companyBranch.Id))
			{
				if (appraiserUser.User.Roles.Count != 1 || appraiserUser.User.Roles.First().RoleType != RoleType.Appraiser || appraiserUser.Status == AppraiserUserStatus.Applied)
					continue;
				if (appraiserUser.Status == AppraiserUserStatus.Inactive && newStatus == AppraisalCompanyStatus.Suspended)
					continue;

				var userStatus = statusMapper.ToUserStatus(newStatus);
				if (newStatus == AppraisalCompanyStatus.Active)
				{
					var historyForCompany = _trackingRepository.GetAppraisalCompanyBranchStatusHistory(companyBranch.Id).FirstOrDefault(e => e.OldValue == AppraisalCompanyStatus.Active.ToString());
					if (historyForCompany != null)
					{
						var history = _trackingRepository.GetAppraiserStatusHistory(appraiserUser.User.Id).ToArray();
						var lastHistory = history.FirstOrDefault(e => e.ChangeEntity.ChangeSet.Date == historyForCompany.ChangeEntity.ChangeSet.Date);

						if (lastHistory == null)
						{
							lastHistory = history.FirstOrDefault(e => e.ChangeEntity.ChangeSet.Date <= historyForCompany.ChangeEntity.ChangeSet.Date);
							if (lastHistory != null)
							{
								userStatus = statusMapper.ToUserStatus(historyMapper.Mapp(lastHistory.NewValue));
							}
						}
						else
						{
							userStatus = statusMapper.ToUserStatus(historyMapper.Mapp(lastHistory.OldValue));
						}
					}
				}

				appraiserUser.Status = userStatus;
			}
		}
示例#3
0
		private void ChangeStatusOfAdminUsers(AppraisalCompanyDetail companyDetail, AppraisalCompanyStatus newStatus, AppraisalCompanyStatus oldStatus)
		{
			if (oldStatus == AppraisalCompanyStatus.Applied)
			{
				var companyStatusMapper = new CompanyUserMapper();
				var rolesOfAdmin = new[] { RoleType.AppraisalCompanyAdmin, RoleType.CompanyAdminAndAppraiser };
				foreach (var appraiserUser in _appraiserManagement.GetUsersForCompany(companyDetail.Id))
				{
					if (appraiserUser.User.Roles.Any(e => rolesOfAdmin.Contains(e.RoleType)))
					{
                        if (appraiserUser.Status == AppraiserUserStatus.Applied && newStatus == AppraisalCompanyStatus.Active)
							appraiserUser.Status = companyStatusMapper.ToUserStatus(newStatus);
					}
				}
			}
		}