public async Task UpdateStatus(int travelrequestId, TravelRequestStatus status, string comments)
        {
            var travelRequest = await _travelRequestRepository.GetAsync(travelrequestId);

            if (travelRequest != null)
            {
                travelRequest.Status = status;
                if (!string.IsNullOrWhiteSpace(comments))
                {
                    if (!string.IsNullOrEmpty(travelRequest.Comments))
                    {
                        travelRequest.Comments = String.Format("{0}{1}{2}", travelRequest.Comments, System.Environment.NewLine, comments);
                    }
                    else
                    {
                        travelRequest.Comments = comments;
                    }
                }
                await _travelRequestRepository.UpdateAsync(travelRequest);

                if (travelRequest.Status == TravelRequestStatus.Approved)
                {
                    TravelsNotificationHub.NotifyApproved(travelRequest);
                }
                await _notificationService.EmailNotifyStatusChange(travelRequest, comments);
            }
        }
        public async Task <int> Add(TravelRequest travelRequest)
        {
            if (travelRequest == null)
            {
                throw new ArgumentNullException("travelRequest");
            }

            var employee = await _employeeRepository.GetAsync(travelRequest.EmployeeId);

            var team = employee.Team;

            if (team == null || team.Manager == null)
            {
                travelRequest.Status = TravelRequestStatus.Approved;
            }

            var newTravelRequestId = await _travelRequestRepository.AddAsync(travelRequest);

            if (team != null)
            {
                var manager = team.Manager;
                if (manager != null)
                {
                    var newTravelRequest = await _travelRequestRepository.GetWithEmployeeInfoAsync(newTravelRequestId);

                    TravelsNotificationHub.NotifyNew(newTravelRequest, manager.Email);
                    await _notificationService.EmailNotifyNewRequest(newTravelRequest);
                }
            }

            return(newTravelRequestId);
        }
Example #3
0
 public IEnumerable <string> TestGetRRHHUsersConnections()
 {
     return(TravelsNotificationHub.GetRRHHUsersConnections());
 }
Example #4
0
 public void TravelsNotificationHub_Constructor_Test()
 {
     var hub = new TravelsNotificationHub();
 }
Example #5
0
 public IEnumerable <string> TestGetUserConnections(string userId)
 {
     return(TravelsNotificationHub.GetUserConnections(userId));
 }