public JsonResult GetLeaveStatus()
        {
            JsonResult result = null;

            try
            {
                EmployeeLeaveDetails employeeLeaveDetails = new EmployeeLeaveDetails();
                employeeLeaveDetails.AppliedStatusCount = Leaveservice.GetLeaveList <EmployeeLeaveList>(s => s.Status == "Applied" && s.BranchId == USER_OBJECT.BranchId && s.EmployeeId == USER_OBJECT.EmployeeId).Count();
                var GrantedLeavesList = Leaveservice.GetLeaveList <EmployeeLeaveList>
                                            (s => s.EmployeeId == USER_OBJECT.EmployeeId && s.BranchId == USER_OBJECT.BranchId)
                                        .GroupBy(g => g.LeaveTypeId).ToList().Select(s => new
                {
                    count = s.Count(),
                    name  = LookUpCodeService.GetLookUpType(s.Key).LookUpCode
                });
                employeeLeaveDetails.GrantedLeaves = Leaveservice.GetLeaveList <EmployeeLeaveList>(s => s.Status == "Grant" && s.BranchId == USER_OBJECT.BranchId && s.EmployeeId == USER_OBJECT.EmployeeId).Count();
                List <LeaveHeader> LeaveHeaders = GrantLeaveService.GetAll <LeaveHeader>(l => l.BranchID == USER_OBJECT.BranchId).ToList();
                var TotalLeaves = LeaveHeaders.Select(l => l.LeaveDetail.Sum(s => s.TotalLeaves)).Count();
                employeeLeaveDetails.RemaingStatusCount = Math.Abs(employeeLeaveDetails.GrantedLeaves - TotalLeaves);
                result = Json(new { employeeLeaveDetails = employeeLeaveDetails, GrantedLeavesList = GrantedLeavesList }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    return(Json(new { success = false, message = ex.InnerException.Message }, JsonRequestBehavior.DenyGet));
                }
            }
            return(result);
        }
        public IActionResult Send_LeaveRequestMail(EmployeeLeaveDetails leavedata)
        {
            string currentMethod = MethodBase.GetCurrentMethod().Name;

            #region Send Mail Code
            try
            {
                StringBuilder MailBody_PM = new StringBuilder();
                // string fileuplaod =   "D:/textfile.txt";
                string fileuplaod = "C:/Users/VAIBHAV/Downloads/Agile.pdf";

                byte[] bytes = System.IO.File.ReadAllBytes(fileuplaod);

                var stream = new MemoryStream(bytes);
                stream.Position = 0;

                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Dear Vaibhav,<br/><br/></font>");

                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Leave Request has been submitted by the below employee -<br/><br/></font>");

                // MailBody_PM.Append("<font face=\"calibri\" size=\"3\" font-weight=\"bold\">Leave Details<br/><br/></font>");


                MailBody_PM.Append("<table width='95%' cellpadding = '5' cellspacing = '0' style = 'border: 1px solid #000000;font-size: \"3\";font-family:calibri'> ");
                MailBody_PM.Append("<tr>");
                MailBody_PM.Append("<th style='background-color: #B8DBFD;border: 1px solid #000000'> Employee Name </th> ");
                MailBody_PM.Append("<th style='background-color: #B8DBFD;border: 1px solid #000000'> Leave Start Date</th> ");
                MailBody_PM.Append("<th style='background-color: #B8DBFD;border: 1px solid #000000'> Leave End Date</th> ");
                MailBody_PM.Append("</tr>");

                MailBody_PM.Append("<tr>");
                MailBody_PM.Append("<td style='text-align:center '>" + leavedata.EmployeeName + "</td>");
                MailBody_PM.Append("<td style='text-align:center '>" + leavedata.LStartDate.Value.Date.ToString("dd MMM yyyy") + "</td>");
                MailBody_PM.Append("<td style='text-align:center'>" + leavedata.LEndDate.Value.Date.ToString("dd MMM yyyy") + "</td>");
                MailBody_PM.Append("</tr>");


                MailBody_PM.Append("</tr></table>");
                MailBody_PM.Append("<br/><br/><br/>");
                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Note: If no action performed on the request, the request will be autorejected after 5 days.</font>");

                MailBody_PM.Append("<br/><br/>");
                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Regards,<br/>Leave Administrator</font><br/><br/></font>");
                MailBody_PM.Append("<font face=\"calibri\" size=\"3\"><hr width=\"96%\"><p style=\"color: red;\"> Note: This is an automatically generated email. Please do not reply directly to this mail.</p></font>");


                Mail ObjMail_PM = new Mail()
                {
                    To = "*****@*****.**",
                    //To = "*****@*****.**",
                    CC = "10670758" + "@lntinfotech.com," + "10643265" + "@lntinfotech.com," + "10655380" + "@lntinfotech.com",
                    //CC = "*****@*****.**",

                    Subject           = "Leave Application requested by Employee",
                    Body              = MailBody_PM.ToString(),
                    Sender            = "*****@*****.**",
                    CallingMethodName = MethodBase.GetCurrentMethod().Name,
                    Status            = "Pending"
                };

                ObjMail_PM.Attachments = new Dictionary <string, Stream>
                {
                    { "Leave_Request_Attachemnt.pdf", stream }
                };

                SendMail(ObjMail_PM);

                return(Ok());
            }
            #endregion

            catch (Exception ex)
            {
                return(BadRequest("Something went wrong"));
            }
        }
        public IActionResult Get_TestMail(EmployeeLeaveDetails LeaveData, string leaveStatus)
        {
            string currentMethod = MethodBase.GetCurrentMethod().Name;

            #region Send Mail Code
            try
            {
                //  using (Proj context = new DevEntity())
                //{


                StringBuilder MailBody_PM = new StringBuilder();


                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Dear " + LeaveData.EmployeeName + ",<br/><br/></font>");
                //MailBody_PM.Append("Dear #Employee_Name#,< br/><br/>");

                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Your Earned Leave application from " + LeaveData.LStartDate.Value.Date.ToString("dd MMM yyyy") + " to " + LeaveData.LEndDate.Value.Date.ToString("dd MMM yyyy") + " has been " + leaveStatus.ToLower() + " by your superior.<br/><br/></font>");

                MailBody_PM.Append("<br/><br/><br/>");
                MailBody_PM.Append("<font face=\"calibri\" size=\"3\">Regards,<br/>Leave Administrator</font><br/><br/></font>");
                MailBody_PM.Append("<font face=\"calibri\" size=\"3\"><hr width=\"96%\"><p style=\"color: red;\"> Note: This is an automatically generated email. Please do not reply directly to this mail.</p></font>");

                // var Get_EmployeeDetails = context.vw_EmployeeData_MyLTI.Where(f => f.Emp_PSNO == assignmentDetails.Emp_PSNO).Select(f => new { f.Emp_PSNO, f.Full_Name }).FirstOrDefault();
                //MailBody_PM.Replace("#Employee_Name#", Get_EmployeeDetails.Emp_Name);
                string status = "";

                if (leaveStatus == "Approved")
                {
                    status = "Approval";
                }
                else
                {
                    status = "Rejection";
                }


                Mail ObjMail_PM = new Mail()
                {
                    To = "*****@*****.**",
                    CC = "10639274" + "@lntinfotech.com," + "10643265" + "@lntinfotech.com," + "10670758" + "@lntinfotech.com",
                    //CC = "*****@*****.**",



                    Subject           = "Automatic " + status + ": Leave Application " + leaveStatus + " by Superior",
                    Body              = MailBody_PM.ToString(),
                    Sender            = "*****@*****.**",
                    CallingMethodName = MethodBase.GetCurrentMethod().Name,
                    Status            = "Pending"
                };
                //MailController obj = new MailController();
                SendMail(ObjMail_PM);

                return(Ok());
            }
            #endregion

            catch (Exception ex)
            {
                return(BadRequest("Something went wrong"));
            }
        }