private string GetNotificationMessage(UpdatePlanResponse response) { var msg = "Le date:<blockquote>{0}</blockquote>sono state {1}."; var days = ConcatDays(response.SavedDates.Length > 0 ? response.SavedDates : response.RemovedDates); var intervals = string.Join(",<br>", days); return(string.Format(msg, intervals, response.SavedDates.Length > 0 ? "aggiunte" : "rimosse")); }
private UpdatePlanResponse AddRejectedLeavesToResponse(ICoverageService coverageService, IList <LeaveDto> leaves, Employe currentEmploye) { var response = new UpdatePlanResponse(); if (leaves?.Count > 0) { var init = leaves.Min(l => l.Date); var end = leaves.Max(l => l.Date); var daysToRemove = coverageService.GetInflexibiltyDays(currentEmploye.Id, init, end).ToList(); daysToRemove = daysToRemove.Where(day => leaves.Any(l => l.Date == day)).ToList(); if (daysToRemove?.Count > 0) { response.RejectedDates = daysToRemove.Select(d => d.ToString(DateIsoFormat)).ToArray(); daysToRemove.ForEach(day => leaves.Remove(leaves.FirstOrDefault(l => l.Date == day))); } } return(response); }
private void SetUpdatedDatesMessage(IList <LeaveDto> addedLeaves, IList <LeaveDto> removedLeaves, UpdatePlanResponse response) { response.SavedDates = (addedLeaves.Count > 0) ? addedLeaves.Select(d => d.Date.ToString(DateIsoFormat)).ToArray() : new string[0]; response.RemovedDates = (removedLeaves.Count > 0) ? removedLeaves.Select(d => d.Date.ToString(DateIsoFormat)).ToArray() : new string[0]; }
private bool SendNotification(NotificationType notificationType, EmployeDto loggedEmploye, EmployeDto targetEmploye, UpdatePlanResponse response) { bool send = notificationType == NotificationType.Approved || notificationType == NotificationType.Rejected; send &= (response.RemovedDates.Length > 0 || response.SavedDates.Length > 0); send &= loggedEmploye.Profile == EmployeProfile.Manager && loggedEmploye.Id != targetEmploye.Id; return(send); }
public void SendNotification(NotificationType notificationType, EmployeDto loggedEmploye, long targetEmployeId, UpdatePlanResponse response, string serverLink) { var targetEmploye = _employeService.GetWithArea(targetEmployeId); if (SendNotification(notificationType, loggedEmploye, targetEmploye, response)) { var param = new ApprovationMailParams(notificationType, serverLink, new[] { GetRecipients(targetEmploye) }, GetNotificationMessage(response), GetSender(loggedEmploye)); SendMail(param).ConfigureAwait(false); } }