示例#1
0
        public ActionResult Index(HttpPostedFileBase file)
        {
            var folderPath = Server.MapPath("~/UploadedFiles/" + Session["UserId"]);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }
            ViewBag.maps = mapListService.GetMapList();
            ViewBag.key  = config.BING_KEY;
            var gpxData = new GpxData();

            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var filePath = Path.Combine(folderPath, fileName);
                    file.SaveAs(filePath);
                    GpxOperationsService gpxOperationsService = new GpxOperationsService(filePath, fileName);
                    gpxData = gpxOperationsService.GpxData;
                }
                catch (Exception e)
                {
                    gpxData = defaultGpxDataService.GetDefaultGpxData();
                    Log.Error(e.Message);
                }
            }
            else
            {
                gpxData = defaultGpxDataService.GetDefaultGpxData();
                Log.Error("File content length error");
            }

            if (gpxData.Lat.Count > 1)
            {
                TempData["Message"] = Resources.Resource.Sent;
            }
            else
            {
                TempData["Message"] = Resources.Resource.Error;
            }
            return(View(gpxData));
        }
示例#2
0
        // GET: GpxRoutes/Details/5
        public ActionResult Details(int?id)
        {
            MapListService mapListService = new MapListService();

            ViewBag.maps = mapListService.GetMapList();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GpxRoute gpxRoute = db.GpxRoutes.Find(id);

            ViewBag.id  = gpxRoute.Id;
            ViewBag.key = config.BING_KEY;
            GpxOperationsService gpxOperationsService = new GpxOperationsService(gpxRoute.FilePath, gpxRoute.Name);
            GpxData gpxData = gpxOperationsService.GpxData;

            if (gpxRoute == null)
            {
                return(HttpNotFound());
            }
            return(View(gpxData));
        }