Exemplo n.º 1
0
 public bool ImportSingleContact(Guid clientId, AllClientsContact contact, Enumerations.WebformType webformType)
 {
     bool result = false;
     using (var ctx = new DomainContext())
     {
         var allClientsContactExport = new AllClientsContactExport { Contact = contact };
         var client = ctx.Client.Single(n => n.Id == clientId);
         allClientsContactExport.Account = AllClientsService.GetAllClientsAccount(client);
         var webForms = AllClientsService.GetAllClientsWebforms(allClientsContactExport.Account);
         allClientsContactExport.AllClientsWebform = webForms.Single(n => n.WebformType == webformType);
         result = AllClientsService.ExportContact(allClientsContactExport).Contains("lblThankYou");
     }
     return result;
 }
Exemplo n.º 2
0
 static AllClientsContact GetTestContact()
 {
     AllClientsContact result = new AllClientsContact
     {
         FirstName = "TestFirstName",
         LastName = "TestLastName",
         City = "TestCity",
         State = "FL",
         Zip = "33333",
         Phone = "1111111111"
     };
     result.Categories.Add(new Category { Id = "1", Name = "TestCategory" });
     result.Flags.Add(new Flag { Id = "1", Name = "TestFlag1" });
     result.Flags.Add(new Flag { Id = "2", Name = "TestFlag2" });
     return result;
 }
Exemplo n.º 3
0
 public static AllClientsContactExport MapToAllClientsContactExport(AllClientsContact contact, List<AllClientsWebform> webforms, AllClientsAccount account)
 {
     var result = new AllClientsContactExport();
     result.Contact = contact;
     result.AllClientsWebform = webforms.SingleOrDefault(n => n.WebformType == (Enumerations.WebformType)Enum.Parse(typeof(Enumerations.WebformType), contact.Categories.First().Id));
     result.Account = account;
     return result;
 }
Exemplo n.º 4
0
        public static string GetAppointmentNotificationComments(AllClientsContact contact)
        {
            //TrainerFirst,TrainerLast,BookedLocation,TypeName,ClassTime,ApptDate
            string result = "";
            var trainerFirstElement = contact.Custom.FirstOrDefault(x => x.Name == "TrainerFirst");
            var trainerLastElement = contact.Custom.FirstOrDefault(x => x.Name == "TrainerLast");
            var bookedLocationElement = contact.Custom.FirstOrDefault(x => x.Name == "BookedLocation");
            var typeNameElement = contact.Custom.FirstOrDefault(x => x.Name == "TypeName");
            var classTimeElement = contact.Custom.FirstOrDefault(x => x.Name == "ClassTime");
            var apptDateElement = contact.Custom.FirstOrDefault(x => x.Name == "ApptDate");

            var trainerFirstVal = trainerFirstElement != null ? trainerFirstElement.Value : "Trainer first name not specified";
            var trainerLastVal = trainerLastElement != null ? trainerLastElement.Value : "Trainer last name not specified";
            var bookedLocationVal = bookedLocationElement != null ? bookedLocationElement.Value : "Location not specified";
            var typeNameVal = typeNameElement != null ? typeNameElement.Value : "Appointment type not specified";
            var classTimeVal = classTimeElement != null ? classTimeElement.Value : "Class Time Not Specified";
            var apptDateVal = apptDateElement != null ? apptDateElement.Value : "Appointment date/time not specified";

            var template = CommonSettings.AppointmentNotificationTemplate
                .Replace(@"\n", System.Environment.NewLine)
                .Replace("~TrainerFirst~", trainerFirstVal)
                .Replace("~TrainerLast~", trainerLastVal)
                .Replace("~BookedLocation~", bookedLocationVal)
                .Replace("~TypeName~", typeNameVal)
                .Replace("~ApptDate~", apptDateVal);
            return template;
        }
Exemplo n.º 5
0
        private static ConversionResult ConvertRowsToContacts(IEnumerable<DataRow> rawRows, IEnumerable<FieldMap> fieldMaps, Category category, Flag flag)
        {
            int successCount = 0, failureCount = 0, duplicateCount = 0;

            var contacts = new List<AllClientsContact>();
            foreach (var rawRow in rawRows)
            {
                var contact = new AllClientsContact();
                contact.FirstName = GetFieldMapValue(rawRow, fieldMaps, "FirstName");
                contact.LastName = GetFieldMapValue(rawRow, fieldMaps, "LastName");
                contact.City = GetFieldMapValue(rawRow, fieldMaps, "City");
                contact.State = GetFieldMapValue(rawRow, fieldMaps, "State");
                contact.Zip = GetFieldMapValue(rawRow, fieldMaps, "Zip");
                contact.Email = GetFieldMapValue(rawRow, fieldMaps, "Email");
                contact.Company = GetFieldMapValue(rawRow, fieldMaps, "Company");
                contact.Phone = GetFieldMapValue(rawRow, fieldMaps, "Phone");
                contact.Categories.Add(category);

                contact.Custom = new List<CustomElement>();
                var birthDate = new CustomElement { Name = "Birthday", Value = GetFieldMapValue(rawRow, fieldMaps, "Birthday") };
                contact.Custom.Add(birthDate);
                contact.Flags.Add(flag);

                if (!contact.IsValid())
                {
                    failureCount++;
                    continue;
                }
                if (contacts.Where(x => x.Email == contact.Email).Count() != 0)
                {
                    duplicateCount++;
                    continue;
                }
                successCount++;
                contacts.Add(contact);
            }
            return new ConversionResult { SuccessCount = successCount, FailureCount = failureCount, DuplicateCount = duplicateCount, Contacts = contacts };
        }
Exemplo n.º 6
0
        public ActionResult SingleContactImport(AllClientsContact contact)
        {
            
            ViewBag.Categories = _xmlRepository.GetAllCategories();
            //ViewBag.Flags = _xmlRepository.GetAllFlags();
            if (!String.IsNullOrEmpty(Request.Form["Birthday"].ToString()))
            {
                var bday = DateTime.Now;
                if (!DateTime.TryParse(Request.Form["Birthday"].ToString(), out bday))
                {
                    ViewData.Add("SingleImportError", "Please ensure Birthday is in the format MM/DD/YYYY");
                    return View();
                }
                else
                {
                    contact.Custom = new List<CustomElement> { new CustomElement { Name = "Birthday", Value = bday.ToShortDateString() } };
                }
            }
            
            
            var category = Request.Form["Category"].Split(',')[1];
            
            if (!contact.IsValid() || category == "")
            {
                ViewData.Add("SingleImportError", "Please ensure the category, first name, last name, and email are filled out.");
            }
            else
            {
                
                ViewData.Add("ImportResult", 1);
                var webFormType = (Enumerations.WebformType)Enum.Parse(typeof(Enumerations.WebformType),category);

                var importer = new ImportService();
                var result = importer.ImportSingleContact(Account.ClientId, contact, webFormType);
                if (result)
                    ViewData["ImportResult"] = 0;
               
            }
            return View();
        }
Exemplo n.º 7
0
        public static AllClientsContactExport MapExportForAppointments(AllClientsContact contact, AllClientsAccount account, IClient client, List<AllClientsWebform> webforms)
        {
            var clientNotificationWebform = webforms.FirstOrDefault(x => x.WebformType == Types.Enumerations.WebformType.AppointmentReminder);
            var ownerNotificationWebForm = webforms.FirstOrDefault(x => x.WebformType == Types.Enumerations.WebformType.AutoNotification);
            if (clientNotificationWebform == null || ownerNotificationWebForm == null)
                return null;

            var apptDateTimeProperty = contact.Custom.SingleOrDefault(x => x.Name == "ApptDate");
            var apptTimeProperty = contact.Custom.SingleOrDefault(x => x.Name == "ClassTime");
            if (apptDateTimeProperty == null || apptTimeProperty == null)
                return null;
            
            var apptDate = System.DateTime.MinValue;
            var apptTime = System.DateTime.MinValue;
        
            if(!DateTime.TryParse(apptDateTimeProperty.Value,out apptDate))
                return null;

            if (!DateTime.TryParse(apptTimeProperty.Value, out apptTime))
                return null;
            apptDate = DateTime.Parse(String.Format("{0} {1}", apptDate.Date.ToShortDateString(), apptTime.TimeOfDay.ToString()));

            var result = new AllClientsContactExport
            {
                Account = account,
                Contact = contact
            };
            contact.Custom.Single(x => x.Name == "ApptDate").Value = apptDate.ToString();
            var comment = AllClientsService.GetAppointmentNotificationComments(contact);
            contact.Custom.Add(new CustomElement { Name = "Comments", Value = comment });

           
            //logic to determine action 
            //if appointment has passed
            if (apptDate.AddDays(Properties.Settings.Default.OwnerNotificationDateRange).Date == System.DateTime.Now.Date)
                result.AllClientsWebform = ownerNotificationWebForm;
                //if the appointment date is tomorrow
            else if (apptDate.Date == System.DateTime.Now.Date.AddDays(Properties.Settings.Default.ClientNotificationDateRange).Date)
                result.AllClientsWebform = clientNotificationWebform;
           
            return result;

        }