コード例 #1
0
        public void When_UpdateEmailAddress_Then_call_correct_methods()
        {
            // Given
            var request = new UpdateEmployeeEmailAddressRequest
                                                         {
                                                             EmployeeId= Guid.NewGuid(),
                                                             Email= "*****@*****.**",
                                                             CompanyId=888L,
                                                             CurrentUserId = Guid.NewGuid()
                                                         };

            var employee = new Mock<Employee>();

            _employeeRepository
                .Setup(x => x.GetByIdAndCompanyId(request.EmployeeId, request.CompanyId))
                .Returns(employee.Object);

            var _userForAudiitng=new UserForAuditing();

            _userForAuditingRepository
                .Setup((x => x.GetByIdAndCompanyId(request.CurrentUserId, request.CompanyId)))
                .Returns(_userForAudiitng);

            var target = GetTarget();

            // When
            target.UpdateEmailAddress(request);

            // Then
            _employeeRepository.Verify(x => x.SaveOrUpdate(employee.Object));
            _userForAuditingRepository.VerifyAll();
            employee.Verify(x => x.SetEmail(request.Email, _userForAudiitng));
        }
コード例 #2
0
        public void UpdateEmailAddress(UpdateEmployeeEmailAddressRequest request)
        {

            var employee = _employeeRepository.GetByIdAndCompanyId(request.EmployeeId, request.CompanyId);
            var currentUser = _userForAuditingRepository.GetByIdAndCompanyId(request.CurrentUserId, request.CompanyId);
            employee.SetEmail(request.Email, currentUser);
            _employeeRepository.SaveOrUpdate(employee);
        }
コード例 #3
0
        public JsonResult UpdateEmployeeEmails(List<EmployeeEmailsViewModel> employeeEmailsViewModel )
        {
            if (employeeEmailsViewModel != null)
            {
                if (employeeEmailsViewModel.Any(x => !IsValidEmailAddress(x.Email)))
                {
                    return Json(new {Success = false, Error = "Valid email address is required"});
                }

                employeeEmailsViewModel
                    .Where(x => !string.IsNullOrEmpty(x.Email))
                    .ToList()
                    .ForEach(x =>
                                 {
                                     //update employee record                               
                                     UpdateEmployeeEmailAddressRequest request = new UpdateEmployeeEmailAddressRequest();
                                     request.CompanyId = CurrentUser.CompanyId;
                                     request.CurrentUserId = CurrentUser.UserId;
                                     request.Email = x.Email;
                                     request.EmployeeId = x.EmployeeId;

                                     _employeeService.UpdateEmailAddress(request);
                                 });

            }
           
            return Json(new { Success = true, Message = "Accident Distribution List Successfully Updated" });
        }