public RegionApiViewModel(Region region)
 {
     Id = region.Id;
     Name = region.Name;
     Description = region.Description;
     Coordinates = region.Coordinates;
 }
 public RegionViewModel(Region region)
 {
     Id = region.Id;
     Name = region.Name;
     Description = region.Description;
     Coordinates = region.Coordinates;
     BaseLayerId = region.BaseLayerId;
     BaseLayerName = region.BaseLayer.Name;
 }
        public long Update(Region model)
        {
            using (var context = new OpenMuseumContext())
            {
                context.Entry(model).State = EntityState.Modified;
                context.SaveChanges();

                return model.Id;
            }
        }
        public long Add(Region model)
        {
            using (var context = new OpenMuseumContext())
            {
                var result = context.Regions.Add(model);
                context.Entry(result).State = EntityState.Added;
                context.SaveChanges();

                return result.Id;
            }
        }
        public ActionResult Add(Region model)
        {
            try
            {
                var regionsRepository = new RegionsRepository();

                regionsRepository.Add(model);

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
        public PageViewModel(Page page, Point point, Region region)
        {
            Id = page.Id;
            Name = page.Name;
            Description = page.Description;
            Content = page.Content;
            ExternalId = page.ExternalId;

            Region = region;
            Point = point;

            PointId = point?.Id;
            PointName = point?.Name;
            RegionId = region?.Id;
            RegionName = region?.Name;

            if (page.Tags != null)
                Tags = page.Tags.Select(x => new TagViewModel(x)).ToList();
        }