Exemple #1
0
        public void SendRequestEmail(Int64 leaveId, string actionName)
        {
            try
            {
                EmailDataModel mdl;
                string         helloUser   = string.Empty;
                string         description = string.Empty;

                using (var client = new LeaveClient())
                {
                    mdl = client.GetEmailData(leaveId, actionName);
                }
                if (mdl.ToEmailId == "AutoApproved")
                {
                    actionName    = "Auto Approved";
                    mdl.ToEmailId = mdl.RequestorEmailId;
                }

                if (actionName == "Pending")
                {
                    helloUser   = mdl.ReportingToName;
                    description = "The request of the below employee is pending for your action:";
                }
                else
                {
                    helloUser   = mdl.RequestFor;
                    description = "Your request has been " + actionName + ".";
                }

                string body = string.Empty;

                body = this.PopulateBody(helloUser, description, mdl.RequestFor, mdl.EmpId, mdl.LeaveTypeText, mdl.Date, mdl.Duration, mdl.Reason, mdl.ReportingToName, mdl.ApproverComments, actionName);

                SendEmail(mdl.ToEmailId, mdl.CcEmailIds, "LMS - Request from " + mdl.RequestFor + " - " + actionName, body);
            }
            catch (Exception ex)
            {
                LogError(ex, leaveId);
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
                throw;
            }
        }