public List <SkillSet> GetAllSkills() { var skillSetList = new List <SkillSet>(); var skillList = _commonDBContext.Query <Skill>().ToList(); foreach (var skill in skillList) { skillSetList.Add(_commonMapper.MapSkillToSkillSet(skill)); } SkillSetSortByName skillSetSortByName = new SkillSetSortByName(); skillSetList.Sort(skillSetSortByName); return(skillSetList); }
public ActionResult SavedNomination(int managerId = 0) { _logger.Log("Nomination-SavedNomination-GET"); var email = User.Identity.Name; _awardService.GetProjectsUnderCurrentUserAsManager(email); _awardService.GetDepartmentsUnderCurrentUserAsManager(email); var nominations = _nominationService.GetAllSubmittedAndSavedNominationsByCurrentUser(managerId); var savedNominations = new List <NominationListViewModel>(); foreach (var nomination in nominations) { var award = _encourageDatabaseContext.Query <Award>().FirstOrDefault(a => a.Id == nomination.AwardId); if (award == null) { continue; } var awardFrequencyCode = _nominationService.GetAwardFrequencyById(award.FrequencyId); var awardName = award.Code; var nominee = _commonDbContext.Query <User>().FirstOrDefault(u => u.ID == nomination.UserId); var nominationTime = nomination.NominationDate; if (nominationTime == null) { continue; } string nominationTimeToDisplay = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(nominationTime.Value.Month) + "-" + nominationTime.Value.Year; if (nominee != null) { var reviewNominationViewModel = new NominationListViewModel() { Intials = nominee.FirstName.Substring(0, 1) + "" + nominee.LastName.Substring(0, 1), AwardName = awardName, DisplayName = nominee.DisplayName, NominationTime = nominationTimeToDisplay, Id = nomination.Id, IsSubmitted = nomination.IsSubmitted, AwardFrequencyCode = awardFrequencyCode.Code, UserId = nominee.ID, EmployeeId = nominee.EmployeeID }; savedNominations.Add(reviewNominationViewModel); } } return(View(savedNominations)); }
public List <UtilityUserRoles> GetAllRolesForUser(string userName) { return(_commmonDBContext.Query <UtilityUserRoles>().Where(x => x.User.UserName == userName).ToList()); }
public List <Utility> GetAllUtilities() { return(_commmonDBContext.Query <Utility>().OrderBy(utility => utility.Name).ToList()); }
private List <ReviewFeedbackListViewModel> ReviewFeedbackList(bool forCurrentMonth, int awardType) { _logger.Log("Review-ReviewFeedbackList-private-GET"); var reviewFeedbacks = new List <ReviewFeedbackListViewModel>(); var awardDetails = _encourageDatabaseContext.Query <Award>().FirstOrDefault(x => x.Id == awardType); DateTime toBeComparedDate = DateTime.Now; List <Shortlist> shortlistedNominations = new List <Shortlist>(); if (awardType != 0) { if (awardDetails != null) { switch (awardDetails.Code) { case "SOM": toBeComparedDate = _customDateService.GetCustomDate(awardType); shortlistedNominations = _encourageDatabaseContext.Query <Shortlist>() .Where(r => r.Nomination.AwardId == awardType && (forCurrentMonth ? (r.Nomination.NominationDate.Value.Month == toBeComparedDate.Month && r.Nomination.NominationDate.Value.Year == toBeComparedDate.Year) : (r.Nomination.NominationDate < toBeComparedDate))) .GroupBy(x => x.NominationId) .Select(group => @group.FirstOrDefault()).ToList(); break; case "PINNACLE": toBeComparedDate = _customDateService.GetCustomDate(awardType); shortlistedNominations = _encourageDatabaseContext.Query <Shortlist>() .Where(r => r.Nomination.AwardId == awardType && (forCurrentMonth ? (r.Nomination.NominationDate.Value.Year == toBeComparedDate.Year) : (r.Nomination.NominationDate.Value.Year < toBeComparedDate.Year))) .GroupBy(x => x.NominationId) .Select(group => @group.FirstOrDefault()).ToList(); break; default: break; } } } else { var listOfAwards = _encourageDatabaseContext.Query <Award>().ToList(); foreach (var award in listOfAwards) { List <Shortlist> listOfNominations; switch (award.Code) { default: case "SOM": toBeComparedDate = _customDateService.GetCustomDate(award.Id); listOfNominations = _encourageDatabaseContext.Query <Shortlist>() .Where(r => r.Nomination.AwardId == award.Id && (forCurrentMonth ? (r.Nomination.NominationDate.Value.Month == toBeComparedDate.Month && r.Nomination.NominationDate.Value.Year == toBeComparedDate.Year) : (r.Nomination.NominationDate < toBeComparedDate))) .GroupBy(x => x.NominationId) .Select(group => group.FirstOrDefault()).ToList(); break; case "PINNACLE": toBeComparedDate = _customDateService.GetCustomDate(award.Id); listOfNominations = _encourageDatabaseContext.Query <Shortlist>() .Where(r => r.Nomination.AwardId == award.Id && (forCurrentMonth ? (r.Nomination.NominationDate.Value.Year == toBeComparedDate.Year) : (r.Nomination.NominationDate.Value.Year < toBeComparedDate.Year))) .GroupBy(x => x.NominationId) .Select(group => group.FirstOrDefault()).ToList(); break; } shortlistedNominations.AddRange(listOfNominations); } } foreach (var shortlistedNomination in shortlistedNominations) { var isShortlisted = false; var isWinner = false; var nomination = _encourageDatabaseContext.Query <Nomination>().SingleOrDefault(x => x.Id == shortlistedNomination.NominationId); var award = _encourageDatabaseContext.Query <Award>().SingleOrDefault(a => a.Id == nomination.AwardId); if (award != null && nomination != null) { var awardFrequency = _nominationService.GetAwardFrequencyById(award.FrequencyId); var isHistorical = IsHistoricalNomination(nomination); var isAwardLocked = GetLockStatusOfAward(nomination.AwardId); var awardCode = award.Code; var nominee = _commonDbContext.Query <User>().FirstOrDefault(u => u.ID == nomination.UserId); var nominationTime = Convert.ToDateTime(nomination.NominationDate); string nominationTimeToDisplay = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(nominationTime.Month) + "-" + nominationTime.Year.ToString(); var totalReviews = _reviewService.GetReviewsForNomination(shortlistedNomination.NominationId).Count(); var reviewerComments = _encourageDatabaseContext.Query <ReviewerComment>().Where(model => model.NominationId == nomination.Id).ToList(); var managerComments = _encourageDatabaseContext.Query <ManagerComment>().Where(model => model.NominationId == nomination.Id).ToList(); decimal totalCreditPoints = 0; decimal averageCredits; foreach (var rc in reviewerComments) { var managerCommnet = managerComments.FirstOrDefault(mc => mc.CriteriaId == rc.CriteriaId); totalCreditPoints += (Convert.ToInt32(rc.Credit) * (managerCommnet != null ? managerCommnet.Weightage : 0) / 100m); } averageCredits = totalCreditPoints / (totalReviews <= 0 ? 1 : totalReviews); var checkResultStatus = _resultService.IsShortlistedOrWinner(nomination.Id); if (checkResultStatus == 1) { isWinner = true; } else if (checkResultStatus == 2) { isShortlisted = true; } if (nominee != null) { reviewFeedbacks.Add( new ReviewFeedbackListViewModel() { AwardName = awardCode, Credits = totalCreditPoints, DisplayName = nominee.DisplayName, Intials = nominee.FirstName.Substring(0, 1) + "" + nominee.LastName.Substring(0, 1), NominationTime = nominationTimeToDisplay, NominationId = nomination.Id, IsShortlisted = isShortlisted, IsWinner = isWinner, NumberOfReviews = totalReviews, AverageCredits = averageCredits, NominatedMonth = nominationTime.Month, AwardFrequencyCode = awardFrequency.Code, IsHistorical = isHistorical, IsAwardLocked = isAwardLocked, EmployeeId = nominee.EmployeeID, UserId = nominee.ID } ); } } } var reviewFeedbackList = reviewFeedbacks.OrderByDescending(o => o.NominatedMonth).ToList(); return(reviewFeedbackList); }
public List <string> GetRoleForUtility(string email, string utiltyName) { var result = _commonDBContext.Query <UtilityUserRoles>().Where(x => x.User.EmailAddress.ToLower() == email.ToLower() && x.Utility.Name.ToLower() == utiltyName.ToLower() && x.IsActive).Select(x => x.Role.Name).ToList(); return(result); }
public List <SuperUser> GetAllSuperUsers() { return(_commmonDBContext.Query <SuperUser>().ToList()); }
public List <User> GetAllUsers() { return(_commonDBContext.Query <User>().OrderBy(user => user.DisplayName).ToList()); }
public List <Role> GetAllRoles() { return(_commmonDBContext.Query <Role>().OrderBy(role => role.Name).ToList()); }
public List <User> GetAllUsersByRoleInUtility(int utilityId, int roleId) { var users = new List <User>(); var utilityUserRoles = _commonDBContext.Query <UtilityUserRoles>().Where(x => x.UtilityId == utilityId && x.RoleId == roleId && x.IsActive).ToList(); if (utilityUserRoles.Count > 0) { foreach (var utilityUserRole in utilityUserRoles) { users.Add(_commonDBContext.Query <User>().FirstOrDefault(x => x.ID == utilityUserRole.UserId)); } } return(users); }
public List <int> GetCurrentMonthHolidays() { return(context.Query <Holiday>().Where(p => p.EventDate.Month == DateTime.Now.Month && p.EventDate.Year == DateTime.Now.Year).Select(p => p.EventDate.Day).ToList()); }
// [CustomeAuthorize(AllowedRole = "Reviewer")] public ActionResult AddExtensionCode(ExtensionSolution extensionSolution) { try { var userEmailAddress = User.Identity.Name; extensionSolution.CreationDate = System.DateTime.Now; extensionSolution.FrequentSearchedCount = 0; User user = new User(); user = _commonDataBaseContext.Query <User>().Where(u => u.EmailAddress == userEmailAddress).FirstOrDefault(); List <UtilityUserRoles> Reviewers = new List <UtilityUserRoles>(); Reviewers = _commonDataBaseContext.Query <UtilityUserRoles>().Where(u => u.UtilityId == 4 && u.RoleId == 371).ToList(); extensionSolution.UserDisplayName = user.DisplayName; extensionSolution.userid = user.ID; List <ExtensionSolution> ExtensionSolutionList = new List <ExtensionSolution>(); ExtensionSolutionList = _extensionCodeService.GetAllExtensionSolution(); var lastItem = ExtensionSolutionList.LastOrDefault(); UtilityUserRoles SelectedReviewer = new UtilityUserRoles(); for (int i = 0; i < Reviewers.Count(); i++) { if (i == Reviewers.Count - 1 || lastItem.reviewerid == 0) { SelectedReviewer = Reviewers[0]; break; } else { if (lastItem.reviewerid == Reviewers[i].UserId) { i = i + 1; SelectedReviewer = Reviewers[i]; break; } } } User reviewer = new User(); reviewer = _commonDataBaseContext.Query <User>().Where(u => u.ID == SelectedReviewer.UserId).FirstOrDefault(); extensionSolution.reviewerid = SelectedReviewer.UserId; _extensionCodeService.AddExtensionSolution(extensionSolution); var reviewerEmailAddresses = reviewer.EmailAddress; //var reviewerEmailAddresses = "*****@*****.**"; var subject = "Review Request for the Extension Code Method."; var userName = user.DisplayName; var codeType = "Extension Code"; var link = "https://reusable.azurewebsites.net/Extension/ReviewExtensionCodeList"; //_extensionCodeService.SendEmail(userName, reviewerEmailAddresses, subject, codeType,link); Task.Factory.StartNew(() => { _extensionCodeService.SendEmail(userName, reviewerEmailAddresses, subject, codeType, link); }); return(RedirectToAction("ShowMyExtensionCode")); } catch (DbUpdateException ex) { ViewBag.message = "Category Name already exists"; return(View(ex)); } catch (Exception e) { return(View(e)); } }