public FileContentResult Export()
        {
            var csvBytes = new byte[0];
            try
            {
                using (var lyconetService = new LyconetService(Db, UserId))
                {
                    csvBytes = lyconetService.GetPeopleContacts();
                }
            }
            catch (Exception e)
            {
                Logger.SetLog(e);
            }

            return File(csvBytes, ExportCsvContentType, ViewResource.PeopleContact_ExportFileName_Text);
        }
Exemple #2
0
        public FileContentResult Export()
        {
            var csvBytes = new byte[0];
            try
            {
                if (ModelState.IsValid)
                {
                    using (var lyconetService = new LyconetService(Db, UserId))
                    {
                        csvBytes = lyconetService.GetTopTen();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.SetLog(e);
            }

            return File(csvBytes, ExportCsvContentType, ExportFileDownloadName);
        }
        public ActionResult Import(Import import)
        {
            import.Validate(this);

            if (ModelState.IsValid)
            {
                try
                {
                    ViewBag.Success = false;

                    using (var lyconetService = new LyconetService(Db, UserId))
                    {
                        lyconetService.ReadDataFromCsvFile(import.File.InputStream);
                        lyconetService.UpdatePeopleContacts();
                        ViewBag.Message = lyconetService.SummaryMessage;
                    }

                    ViewBag.Success = true;
                }
                catch (Exception e)
                {
                    ViewBag.Message = String.Format(ValidationResource.PeopleContact_ParsingCsv_ErrorMessage, e.Message);
                }

                return View("ImportSummary");
            }

            return View(import);
        }