Exemplo n.º 1
0
        public void SendEmailforAddLeave(List <EmployeeLeaveBalanceDetails> lst)
        {
            try
            {
                Int64 leaveTypeId = 0;
                if (lst.Count() > 0)
                {
                    for (int i = 0; i < lst.Count(); i++)
                    {
                        if (lst[i].NoOfDays > 0)
                        {
                            EmailDataModel mdl;
                            string         description = string.Empty;
                            leaveTypeId = Convert.ToInt64(lst[i].LeaveTypeId);
                            using (var client = new LeaveClient())
                            {
                                mdl = client.GetEmailDataAddLeave(Convert.ToInt64(lst[i].UserId), leaveTypeId);
                            }

                            description = "Your " + mdl.LeaveTypeText + " balance has been updated.";

                            string body        = string.Empty;
                            string transaction = lst[i].CreditOrDebit == "C" ? "Credit" : "Debit";
                            body = this.PopulateBodyforAddLeave(mdl.RequestFor, description, mdl.EmpId, mdl.LeaveTypeText, lst[i].BalanceDays.ToString(), transaction, lst[i].NoOfDays.ToString(), lst[i].TotalDays.ToString(), lst[i].Remarks);

                            SendEmail(mdl.RequestorEmailId, mdl.CcEmailIds, "LMS - " + mdl.RequestFor + " - " + mdl.LeaveTypeText + " balance updated", body);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
                throw;
            }
        }