Пример #1
0
        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);
        }