private void SendTicketGenerationEmailAlert(TicketViewModel ticketViewModel) { var GMT = Convert.ToInt32(Session["ClientGMT"]); var employeeEmail = Session["EmployeeEmail"].ToString(); var employeeData = employeeService.GetEmployeeData(ticketViewModel.Ticket.EmployeeId); List <string> employeeSupervisorsEmailsList = new List <string>(); var ticketType = ticketTypeService.GetAllActiveTicketTypes().FirstOrDefault(x => x.TicketTypeId == ticketViewModel.Ticket.TicketTypeId); if (ticketType != null && ticketType.IsLeave) { employeeSupervisorsEmailsList = employeeData.EmployeeSupervisors.ToList().Select(x => x.Supervisor.AspNetUser.Email).ToList(); var HREmails = aspNetUserService.GetAllUsersEmailOfSpecificRole("HR"); employeeSupervisorsEmailsList.AddRange(HREmails); } else { var HREmails = aspNetUserService.GetAllUsersEmailOfSpecificRole("HR"); employeeSupervisorsEmailsList.AddRange(HREmails); } var employeeSupervisorsEmailsString = string.Join(",", employeeSupervisorsEmailsList); var employeeName = employeeData.Employee.FullName; var callbackUrl = Url.Action("Index", "Ticket", null, protocol: Request.Url.Scheme); string message = employeeName + " has generated a " + ticketViewModel.Ticket.TicketTitle + " Ticket on " + Utility.ConvertTimeByGMT(GMT, currentTime) + ".<br/> Kindly review the details <a href=\"" + callbackUrl + "\">here</a>"; UserManager.SendAttendanceEmailAsync(employeeEmail, ticketViewModel.Ticket.TicketTitle + " Ticket - Alert", message, employeeSupervisorsEmailsString); }
private void SendAttendanceEmailAlert(AttendanceModel attendanceWebModel, bool threshHold) { var GMT = Convert.ToInt32(Session["ClientGMT"]); var employeeEmail = Session["EmployeeEmail"].ToString(); var employeeData = employeeService.GetEmployeeData(attendanceWebModel.EmployeeId); List <string> employeeSupervisorsEmailsList = employeeData.EmployeeSupervisors.ToList().Select(x => x.Supervisor.AspNetUser.Email).ToList(); var HrEmails = aspNetUserService.GetAllUsersEmailOfSpecificRole("HR"); employeeSupervisorsEmailsList.AddRange(HrEmails); var employeeSupervisorsEmailsString = string.Join(",", employeeSupervisorsEmailsList); var employeeName = employeeData.Employee.FullName; string threshHoldMessage = string.Empty; if (threshHold) { threshHoldMessage = " and half leave has been marked for today"; TicketModel ticket = new TicketModel { EmployeeId = Convert.ToInt32(Session["EmployeeId"].ToString()), TicketTypeId = Convert.ToInt32(ConfigurationManager.AppSettings["HalfDayLeave"]), RecCreatedBy = User.Identity.GetUserId(), RecLastUpdatedBy = User.Identity.GetUserId(), RecCreatedOn = currentTime, RecLastUpdateOn = currentTime, Reason = "This is auto generated reason, Employee Check-in time was " + Utility.ConvertTimeByGMT(GMT, currentTime) }; ticketService.SaveTicket(ticket.MapFromClientToServer()); } string message = employeeName + " is late," + threshHoldMessage + " . Employee Checked-in at " + Utility.ConvertTimeByGMT(GMT, currentTime) + ". <br/><i>Admin has been notified by email.</i>"; UserManager.SendAttendanceEmailAsync(employeeEmail, "Late Attendance - Alert", message, employeeSupervisorsEmailsString); }