public void SaveCallCriteriaInitialAdviseCallCriteriaEmailResources(CS_CallLog initialAdvise)
        {
            try
            {
                IList<CS_CallLogCallCriteriaEmail> emailSaveList = new List<CS_CallLogCallCriteriaEmail>();

                IList<EmailVO> resourceList = _callCriteriaModel.ListReceiptsByCallLog(initialAdvise.CallTypeID.ToString(), initialAdvise.JobID, initialAdvise);

                for (int i = 0; i < resourceList.Count; i++)
                {
                    // Because of the Type, we need to separate the PersonID in two different variables
                    int? employeeId = null;
                    int? contactId = null;
                    if (resourceList[i].Type == (int)Globals.CallCriteria.EmailVOType.Employee)
                        employeeId = resourceList[i].PersonID;
                    else
                        contactId = resourceList[i].PersonID;

                    CS_CallLogCallCriteriaEmail emailResource = new CS_CallLogCallCriteriaEmail()
                    {
                        CallLogID = initialAdvise.ID,
                        Name = resourceList[i].Name,
                        Email = resourceList[i].Email,
                        Status = (int)Globals.CallCriteria.CallCriteriaEmailStatus.Pending,
                        StatusDate = DateTime.Now,
                        //CreationID = ,
                        CreatedBy = initialAdvise.CreatedBy,
                        CreationDate = DateTime.Now,
                        //ModificationID,
                        ModifiedBy = initialAdvise.ModifiedBy,
                        ModificationDate = DateTime.Now,
                        Active = true
                    };

                    emailSaveList.Add(emailResource);
                }

                _callLogCallCriteriaEmailRepository.AddList(emailSaveList);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save the Initial Advise Resources.", ex);
            }
        }
        /// <summary>
        /// Generates records for a FirstAlert Call Criteria Resources
        /// </summary>
        /// <param name="initialAdvise">Generated Initial Advise Call Log</param>
        private IList<EmailVO> SaveCallCriteriaFirstAlertResources(CS_CallLog firstAlert)
        {
            try
            {
                IList<CS_CallLogResource> saveList = new List<CS_CallLogResource>();
                IList<CS_CallLogCallCriteriaEmail> emailSaveList = new List<CS_CallLogCallCriteriaEmail>();

                IList<EmailVO> resourceList = _callCriteriaModel.ListReceiptsByCallLog(firstAlert.CallTypeID.ToString(), firstAlert.JobID, firstAlert);

                for (int i = 0; i < resourceList.Count; i++)
                {
                    // Because of the Type, we need to separate the PersonID in two different variables
                    int? employeeId = null;
                    int? contactId = null;
                    if (resourceList[i].Type == (int)Globals.CallCriteria.EmailVOType.Employee)
                        employeeId = resourceList[i].PersonID;
                    else
                        contactId = resourceList[i].PersonID;

                    CS_CallLogResource resource = new CS_CallLogResource()
                    {
                        CallLogID = firstAlert.ID,
                        EmployeeID = employeeId,
                        ContactID = contactId,
                        JobID = firstAlert.JobID,
                        Type = resourceList[i].Type,
                        CreatedBy = firstAlert.CreatedBy,
                        CreationDate = DateTime.Now,
                        ModifiedBy = firstAlert.ModifiedBy,
                        ModificationDate = DateTime.Now,
                        Active = true
                    };

                    saveList.Add(resource);

                    CS_CallLogCallCriteriaEmail emailResource = new CS_CallLogCallCriteriaEmail()
                    {
                        CallLogID = firstAlert.ID,
                        Name = resourceList[i].Name,
                        Email = resourceList[i].Email,
                        Status = (int)Globals.CallCriteria.CallCriteriaEmailStatus.Pending,
                        StatusDate = DateTime.Now,
                        //CreationID = ,
                        CreatedBy = firstAlert.CreatedBy,
                        CreationDate = DateTime.Now,
                        //ModificationID,
                        ModifiedBy = firstAlert.ModifiedBy,
                        ModificationDate = DateTime.Now,
                        Active = true
                    };

                    emailSaveList.Add(emailResource);
                }

                _callLogResourceRepository.AddList(saveList);

                _callLogCallCriteriaEmailRepository.AddList(emailSaveList);

                return resourceList;
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save the First Alert Resources.", ex);
            }
        }
 private IList<CS_CallLogCallCriteriaEmail> CreateDeleteCallLogCallCriteriaEmailEntity()
 {
     IList<CS_CallLogCallCriteriaEmail> callCriteriaEmailToDelete = new List<CS_CallLogCallCriteriaEmail>();
     //Creating int list because the method to list call criteria emails already exists
     List<int> callLogIdList = new List<int>();
     callLogIdList.Add(_view.CallLogIdToDelete);
     IList<CS_CallLogCallCriteriaEmail> oldcallCriteriaEmail = _callLogModel.ListCallCriteriaEmails(callLogIdList);
     for (int i = 0; i < oldcallCriteriaEmail.Count; i++)
     {
         CS_CallLogCallCriteriaEmail callCriteriaEmail = new CS_CallLogCallCriteriaEmail();
         callCriteriaEmail.ID = oldcallCriteriaEmail[i].ID;
         callCriteriaEmail.CallLogID = oldcallCriteriaEmail[i].CallLogID;
         callCriteriaEmail.EmailID = oldcallCriteriaEmail[i].EmailID;
         callCriteriaEmail.Name = oldcallCriteriaEmail[i].Name;
         callCriteriaEmail.Email = oldcallCriteriaEmail[i].Email;
         callCriteriaEmail.Status = oldcallCriteriaEmail[i].Status;
         callCriteriaEmail.StatusDate = oldcallCriteriaEmail[i].StatusDate;
         callCriteriaEmail.CreatedBy = oldcallCriteriaEmail[i].CreatedBy;
         callCriteriaEmail.CreationDate = oldcallCriteriaEmail[i].CreationDate;
         callCriteriaEmail.ModifiedBy = _view.UserName;
         callCriteriaEmail.ModificationDate = DateTime.Now;
         callCriteriaEmail.Active = false;
         callCriteriaEmailToDelete.Add(callCriteriaEmail);
     }
     return callCriteriaEmailToDelete;
 }