Ejemplo n.º 1
0
 public ImportController()
 {
     string fileName = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/App_Data"), "LookUps.xml");
     _xmlRepository = new XmlRepository(fileName);
     _importService = new ImportService(_xmlRepository);
 
 }
Ejemplo n.º 2
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();
        }