public int Add(VacationRequest vacationRequest)
        {
            TraceManager.TraceError("Add vacation request");


            if (vacationRequest == null)
            {
                throw new ArgumentNullException("vacationRequest");
            }

            var employee = _employeeRepository.GetByEmail(_securityHelper.GetUser(), PictureType.Small);

            vacationRequest.EmployeeId = employee.EmployeeId;
            var newVacationRequestId = _vacationRequestRepository.Add(vacationRequest);
            var newVacationRequest   = _vacationRequestRepository.Get(newVacationRequestId);

            TraceManager.TraceError("before if and Calling notify new in VacationHub");
            if (employee.Team != null && employee.Team.Manager != null)
            {
                TraceManager.TraceError("Calling notify new in VacationHub");
                VacationNotificationHub.NotifyNew(newVacationRequest, employee.Team.Manager.Email);
            }
            _vacationNotificationService.NotifyNewVacationRequest(vacationRequest);

            return(newVacationRequest.VacationRequestId);
        }
        protected override VacationRequest CreateEntity(VacationRequest entity)
        {
            var identity = _securityHelper.GetUser();

            var employee = _context.Employees
                           .Include("Team.Manager")
                           .Single(e => e.Email == identity);

            entity.EmployeeId = employee.EmployeeId;

            _vacationRequestRepository.Add(entity);


            //To avoid cirucular references in serialization
            entity.Employee.VacationRequests = null;

            if (employee.Team != null && employee.Team.Manager != null)
            {
                VacationNotificationHub.NotifyNew(entity, employee.Team.Manager.Email);
            }
            _vacationNotificationService.NotifyNewVacationRequest(entity);

            return(entity);
        }