public ViewResult InteractionEventDetail(InteractionEventPrimaryKey interactionEventPrimaryKey)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;

            var mapLocationFormID = GetMapLocationFormID(interactionEventPrimaryKey);

            //the following variables are plural because the MapInitJson constructor is expecting List<>s but InteractionEvents only have a single location point associated with them.
            var         layers           = new List <LayerGeoJson>();
            var         locationFeatures = new List <Feature>();
            BoundingBox boundingBox      = null;

            if (interactionEvent.InteractionEventLocationSimple != null)
            {
                locationFeatures.Add(DbGeometryToGeoJsonHelper.FromDbGeometry(interactionEvent.InteractionEventLocationSimple));
                boundingBox = new BoundingBox(new Point(interactionEvent.InteractionEventLocationSimple), 0.5m);
            }

            if (locationFeatures.Any())
            {
                layers.Add(new LayerGeoJson($"{FieldDefinition.InteractionEvent.FieldDefinitionDisplayName} Location",
                                            new FeatureCollection(locationFeatures), "yellow", 1,
                                            LayerInitialVisibility.Show));
            }

            var interactionEventLocationMapInitJson = new MapInitJson($"interactionEvent_{interactionEvent.InteractionEventID}_mapID", 10, layers, boundingBox);
            var viewData = new InteractionEventDetailViewData(CurrentPerson, interactionEvent, mapLocationFormID, interactionEventLocationMapInitJson);

            return(RazorView <InteractionEventDetail, InteractionEventDetailViewData>(viewData));
        }
        public PartialViewResult EditInteractionEventLocation(InteractionEventPrimaryKey interactionEventPrimaryKey)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;
            var viewModel        = new EditInteractionEventLocationSimpleViewModel(interactionEvent.InteractionEventLocationSimple);

            return(ViewEditInteractionEventLocationSimple(viewModel, interactionEvent));
        }
        public PartialViewResult NewInteractionEventFiles(InteractionEventPrimaryKey interactionEventPrimaryKey)
        {
            Check.EnsureNotNull(interactionEventPrimaryKey.EntityObject);
            var viewModel = new NewFileViewModel();

            return(ViewNewInteractionEventFiles(viewModel));
        }
        public ActionResult NewInteractionEventFiles(InteractionEventPrimaryKey interactionEventPrimaryKey, NewFileViewModel viewModel)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewNewInteractionEventFiles(new NewFileViewModel()));
            }

            viewModel.UpdateModel(interactionEvent, CurrentPerson);
            SetMessageForDisplay($"Successfully created {viewModel.FileResourcesData.Count} new files(s) for {FieldDefinition.InteractionEvent.GetFieldDefinitionLabel()} \"{interactionEvent.InteractionEventTitle}\".");
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult EditInteractionEventLocation(InteractionEventPrimaryKey interactionEventPrimaryKey, EditInteractionEventLocationSimpleViewModel viewModel)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditInteractionEventLocationSimple(viewModel, interactionEvent));
            }

            viewModel.UpdateModel(interactionEvent);

            HttpRequestStorage.DatabaseEntities.SaveChanges();

            return(new ModalDialogFormJsonResult());
        }
        public ActionResult DeleteInteractionEvent(InteractionEventPrimaryKey interactionEventPrimaryKey, ConfirmDialogFormViewModel viewModel)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewDeleteInteractionEvent(interactionEvent, viewModel));
            }

            var message = $"{FieldDefinition.InteractionEvent.GetFieldDefinitionLabel()} \"{interactionEvent.InteractionEventTitle}\" successfully deleted.";

            interactionEvent.DeleteFullAndChildless(HttpRequestStorage.DatabaseEntities);

            SetMessageForDisplay(message);
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult EditInteractionEvent(InteractionEventPrimaryKey interactionEventPrimaryKey, EditInteractionEventViewModel viewModel)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(InteractionEventViewEdit(viewModel, EditInteractionEventEditType.ExistingInteractionEventEdit));
            }
            HttpRequestStorage.DatabaseEntities.InteractionEventProjects.Load();
            var interactionEventProjects = HttpRequestStorage.DatabaseEntities.InteractionEventProjects.Local;

            HttpRequestStorage.DatabaseEntities.InteractionEventContacts.Load();
            var interactionEventContacts = HttpRequestStorage.DatabaseEntities.InteractionEventContacts.Local;

            viewModel.UpdateModel(interactionEvent, CurrentPerson, interactionEventProjects, interactionEventContacts);

            HttpRequestStorage.DatabaseEntities.SaveChanges();

            return(new ModalDialogFormJsonResult());
        }
        public PartialViewResult EditInteractionEvent(InteractionEventPrimaryKey interactionEventPrimaryKey)
        {
            var viewModel = new EditInteractionEventViewModel(interactionEventPrimaryKey.EntityObject);

            return(InteractionEventViewEdit(viewModel, EditInteractionEventEditType.ExistingInteractionEventEdit));
        }
        public PartialViewResult InteractionEventMapPopup(InteractionEventPrimaryKey interactionEventPrimaryKey)
        {
            var interactionEvent = interactionEventPrimaryKey.EntityObject;

            return(RazorPartialView <InteractionEventMapPopup, InteractionEventMapPopupViewData>(new InteractionEventMapPopupViewData(interactionEvent)));
        }
 private string GetMapLocationFormID(InteractionEventPrimaryKey interactionEventPrimaryKey)
 {
     return($"editMapForInteractionEventLocation{interactionEventPrimaryKey}");
 }
        public PartialViewResult DeleteInteractionEvent(InteractionEventPrimaryKey interactionEventPrimaryKey)
        {
            var viewModel = new ConfirmDialogFormViewModel(interactionEventPrimaryKey.PrimaryKeyValue);

            return(ViewDeleteInteractionEvent(interactionEventPrimaryKey.EntityObject, viewModel));
        }