public RecommendationNotificationDto GetRecommendationNotification(int notificationId) { RecommendationNotificationDto resultDto = null; var recommendationResults = _entities.Where(rc => rc.Notification.Id == notificationId) .Include(rc => rc.Notification); if (recommendationResults != null && recommendationResults.Count() > 0) { var recommendationResult = recommendationResults.First(); // Update the notification recommendationResult.Notification.IsViewed = true; _context.SaveChanges(); resultDto = Mapper.Map <RecommendationNotificationDto>(recommendationResult); var candidates = _context.Set <CandidateUser>().Where(c => c.Id == resultDto.CandidateId) .Include(c => c.Identity); if (candidates != null && candidates.Count() > 0) { var relevantUser = candidates.First(); resultDto.CandidateFirstName = relevantUser.Identity.FirstName; resultDto.CandidateLastName = relevantUser.Identity.LastName; } } return(resultDto); }
public RecommendationNotificationDto GetRecommendationNotification(int notificationId) { RecommendationNotificationDto result = null; try { result = new RecommendationNotificationsRepository(_appDbContext).GetRecommendationNotification(notificationId); } catch (Exception e) { _log.LogError(e, "Error getting recommendation notification"); } return(result); }
public RecommendationNotificationDto UpdateFeedback(int notificationId, bool isApproved) { RecommendationNotificationDto recommendation = null; try { recommendation = new RecommendationNotificationsRepository(_appDbContext).UpdateFeedback(notificationId, isApproved); } catch (Exception e) { _log.LogError(e, "Error updating recommendation feedback"); } return(recommendation); }
public RecommendationNotificationDto UpdateFeedback(int notificationId, bool isApproved) { RecommendationNotificationDto result = null; var recommendations = Find(rn => rn.Notification.Id == notificationId); var updatedRecommendation = recommendations.First(); if (updatedRecommendation != null) { updatedRecommendation.Approved = isApproved; updatedRecommendation.DateResponded = DateTime.Now; _context.Set <Position>(); new PositionsRepository(_context) .AddCandidateToPotentials( updatedRecommendation.PositionId, updatedRecommendation.CandidateId, CandidatePositionStatus.Recommended); _context.SaveChanges(); result = Mapper.Map <RecommendationNotificationDto>(updatedRecommendation); } return(result); }