Exemplo n.º 1
0
        public ActionResult Index(HttpPostedFileBase file, string parentPath)
        {
            EventsService service = new EventsService();

            using (var reader = new System.IO.StreamReader(file.InputStream))
            {
                var contents = reader.ReadToEnd();
                try
                {
                    IEnumerable <Event> events = JsonConvert.DeserializeObject <IEnumerable <Event> >(contents);

                    var database = Sitecore.Configuration.Factory.GetDatabase("master");
                    var parent   = database.GetItem(parentPath);

                    service.AddItems(parent, events, EventDetails.templateID);
                }
                catch (Exception ex)
                {
                    //to do
                }
            }

            ViewBag.Message = string.Format("{0} updated, {1} added.", service.UpdateCount, service.AddCount);
            return(View());
        }