コード例 #1
0
        // GET: DataLayer
        public DataLayerApiViewModel GetDataLayer(long id)
        {
            var dataLayersRepository = new DataLayersRepository();
            var model = dataLayersRepository.GetById(id);

            return new DataLayerApiViewModel(model);
        }
コード例 #2
0
        // GET: BaseLayers/Delete/5
        public ActionResult Delete(int id)
        {
            var dataLayersRepository = new DataLayersRepository();

            var model = dataLayersRepository.GetById(id);

            if (model != null)
                return View(model);
            return HttpNotFound();
        }
コード例 #3
0
        // GET: DataLayers
        public IEnumerable<DataLayerApiViewModel> GetAllDataLayers()
        {
            IDisposable context;

            var dataLayersRepository = new DataLayersRepository();
            var layers = dataLayersRepository.GetAll(out context).ToList();

            var result = layers.Select(layer => new DataLayerApiViewModel(layer)).ToList();

            context.Dispose();

            return result;
        }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                var dataLayersRepository = new DataLayersRepository();

                dataLayersRepository.Delete(id);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #5
0
        public ActionResult Add(DataLayer model)
        {
            try
            {
                var dataLayersRepository = new DataLayersRepository();

                dataLayersRepository.Add(model);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #6
0
        // GET: BaseLayers/Create
        public ActionResult Add()
        {
            var baseLayersRepository = new BaseLayersRepository();
            IDisposable context = null;

            ViewBag.ListOfBaseLayers = baseLayersRepository.GetAll(out context).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });

            context?.Dispose();

            var dataLayersRepository = new DataLayersRepository();
            ViewBag.ListOfDataLayers = dataLayersRepository.GetAll(out context).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });
            context?.Dispose();

            return View(new DataLayer());
        }
コード例 #7
0
        public ActionResult Add(EditPointViewModel model)
        {
            try
            {
                var pointsRepository = new PointsRepository();
                var dataLayersRepository = new DataLayersRepository();

                var point = new Point()
                {
                    Name = model.Name,
                    Description = model.Description,
                    Latitude = model.Latitude,
                    Longitude = model.Longitude,
                    Coordinates = model.Coordinates,
                    PageId = model.PageId,
                    RegionId = model.RegionId
                };

                if (model.SelectedDataLayers != null)
                {
                    var dataLayers = dataLayersRepository.GetByStringIds(model.SelectedDataLayers);
                    point.DataLayers = new List<DataLayer>(dataLayers);
                }
                else
                {
                    point.DataLayers = null;
                }

                pointsRepository.Add(point);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #8
0
        // GET: BaseLayers/Create
        public ActionResult Add()
        {
            var dataLayersRepository = new DataLayersRepository();
            var regionsRepository = new RegionsRepository();

            IDisposable context = null;

            ViewBag.ListOfRegions = regionsRepository.GetAll(out context).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });

            context?.Dispose();

            var baseLayersRepository = new BaseLayersRepository();
            IDisposable context3;

            var baseLayers = baseLayersRepository.GetAll(out context3).ToList();

            ViewBag.BaseLayerUrl = baseLayers.FirstOrDefault()?.Url;
            context3?.Dispose();

            IDisposable context1;

            ViewBag.ListOfDataLayers = dataLayersRepository.GetAll(out context1).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });

            using (context1)
            {
                return View(new EditPointViewModel(new Point()));
            }
        }
コード例 #9
0
        public ActionResult Edit(EditPointViewModel model)
        {
            try
            {
                var dataLayersRepository = new DataLayersRepository();

                var pointsRepository = new PointsRepository();
                var originalPoint = pointsRepository.GetById(model.Id);

                if (model.SelectedDataLayers != null)
                {
                    var dataLayers = dataLayersRepository.GetByStringIds(model.SelectedDataLayers);
                    originalPoint.DataLayers = new List<DataLayer>(dataLayers);
                }
                else
                {
                    originalPoint.DataLayers = null;
                }

                originalPoint.Name = model.Name;
                originalPoint.Description = model.Description;
                originalPoint.Latitude = model.Latitude;
                originalPoint.Longitude = model.Longitude;
                originalPoint.PageId = model.PageId;
                originalPoint.RegionId = model.RegionId;
                originalPoint.Coordinates = model.Coordinates;

                pointsRepository.Update(originalPoint);

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
コード例 #10
0
        // GET: BaseLayers/Edit/5
        public ActionResult Edit(long id)
        {
            var dataLayersRepository = new DataLayersRepository();
            var pointsRepository = new PointsRepository();
            var regionsRepository = new RegionsRepository();

            var model = pointsRepository.GetById(id);
            var dataLayersIds = model.DataLayers != null ? model.DataLayers.Select(x => x.Id) : new List<long>();

            IDisposable context;

            ViewBag.ListOfDataLayers = dataLayersRepository.GetAll(out context).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name,
                Selected = dataLayersIds.Contains(x.Id)
            });

            context?.Dispose();

            IDisposable context1 = null;

            ViewBag.ListOfRegions = regionsRepository.GetAll(out context1).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });

            context1?.Dispose();

            var baseLayersRepository = new BaseLayersRepository();
            IDisposable context3;

            var baseLayers = baseLayersRepository.GetAll(out context3).ToList();

            ViewBag.BaseLayerUrl = baseLayers.FirstOrDefault()?.Url;
            context3?.Dispose();

            if (model != null)
                return View(new EditPointViewModel(model));
            return HttpNotFound();
        }
コード例 #11
0
        // GET: BaseLayers
        public ActionResult Index()
        {
            var dataLayersRepository = new DataLayersRepository();

            IDisposable context;
            var layers = dataLayersRepository.GetAll(out context).ToList().Select(x => new DataLayerViewModel(x)).ToList();

            using (context)
            {
                return View(layers);
            }
        }
コード例 #12
0
        public ActionResult Edit(DataLayer model)
        {
            try
            {
                var dataLayersRepository = new DataLayersRepository();

                dataLayersRepository.Update(model);

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
コード例 #13
0
        // GET: BaseLayers/Edit/5
        public ActionResult Edit(long id)
        {
            var baseLayersRepository = new BaseLayersRepository();
            IDisposable context;

            ViewBag.ListOfBaseLayers = baseLayersRepository.GetAll(out context).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });
            context?.Dispose();

            var dataLayersRepository = new DataLayersRepository();
            ViewBag.ListOfDataLayers = dataLayersRepository.GetAll(out context).ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            });
            context?.Dispose();

            var model = dataLayersRepository.GetById(id);

            if (model != null)
                return View(model);
            return HttpNotFound();
        }