示例#1
0
        public async Task <IDataProvider> Import(IReadSeekStreamFactory readerFactory, Dictionary <string, object> parameters)
        {
            var importer = new GarminImporter(readerFactory, parameters["Name"] as string);

            importer.ParseFile(await readerFactory.GetReadStream());
            return(importer);
        }
        public ActionResult Import(int personId, HttpPostedFileBase file)
        {
            ViewBag.PersonId = new SelectList(MembershipProvider.ReadAll(), "Id", "Name", personId);

            //TODO: Pull this out into a business class
            try
            {
                if (file.ContentLength > 0)
                {
                    var data = ParseCsv(file);

                    var importer = new GarminImporter();
                    importer.Import(data, personId);

                    ViewBag.Message = "File Uploaded Successfully!!";
                }
                else
                {
                    ViewBag.Message = "The selected file was empty or not found!";
                }
                return(View());
            }
            catch (Exception ex)
            {
                ViewBag.Message = "File upload failed! " + ex.Message;
                return(View());
            }
        }