Esempio n. 1
0
        private void GetSMSrecipientsDefinitions()
        {
            //create recipients reader instance
            SMSrecipientReader reader = new SMSrecipientReader(_realmProvider);

            //read all rcipients from DB
            List <SMSrecipientDefinition> allRecipients = reader.GetAllActualRecipients();

            //read all recipients to export definitions
            foreach (var item in _recipientsIDList)
            {
                try
                {
                    //convert realm DB model into export model
                    SMSrecipientDefinition definition = allRecipients.Where(x => x.Identity == item).First();

                    SMSrecipientDefinitionExportModel exportModel = new SMSrecipientDefinitionExportModel()
                    {
                        Identity    = definition.Identity,
                        FirstName   = definition.FirstName,
                        LastName    = definition.LastName,
                        AreaCode    = definition.AreaCode,
                        PhoneNumber = definition.PhoneNumber,
                        NoErrors    = true,
                    };

                    _recipientsList.Add(exportModel);
                }
                catch (Exception ex)
                {
                    var logger = NLog.LogManager.GetCurrentClassLogger();
                    logger.Error($"Error while searching for {item} identity in actual SMS recipients group. Error: {ex.Message}.");
                }
            }
        }
Esempio n. 2
0
        private bool CheckIfSMSrecipientWithThisNameExists(SMSrecipientDefinitionExportModel parsedRecipient)
        {
            //create instance of sms recipients reader
            SMSrecipientReader            reader        = new SMSrecipientReader(_realmProvider);
            List <SMSrecipientDefinition> allRecipients = reader.GetAllActualRecipients();

            return(allRecipients.Where(x => x.FirstName == parsedRecipient.FirstName && x.LastName == parsedRecipient.LastName).Count() > 0);
        }
Esempio n. 3
0
        private void SaveRecipientToDB(SMSrecipientCreator creator, SMSrecipientDefinitionExportModel definition)
        {
            bool added = creator.AddNewSMSrecipient(definition.FirstName, definition.LastName,
                                                    definition.AreaCode, definition.PhoneNumber);

            string message;

            if (added)
            {
                message = $"SMS recipient successfully added to database.";
            }
            else
            {
                message = $"SMS recipient NOT ADDED to Database.";
            }

            OnSingleImportDone(added, definition.FullName, message, false);
        }
Esempio n. 4
0
 private bool CheckCorrectnessOfData(SMSrecipientDefinitionExportModel parsedRecipient,
                                     SMSrecipientImportItemValidator validaror)
 {
     return(validaror.Validate(parsedRecipient).NoErrors);
 }