Ejemplo n.º 1
0
        public ActionResult SetKeyPhoto(ProjectImagePrimaryKey projectImagePrimaryKey)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;

            projectImage.SetAsKeyPhoto();
            return(new ModalDialogFormJsonResult());
        }
Ejemplo n.º 2
0
        public PartialViewResult Edit(ProjectImagePrimaryKey projectImagePrimaryKey)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;
            var viewModel    = new EditViewModel(projectImage);

            return(ViewEdit(projectImage, viewModel));
        }
Ejemplo n.º 3
0
        public PartialViewResult DeleteProjectImage(ProjectImagePrimaryKey projectImagePrimaryKey)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;
            var viewModel    = new ConfirmDialogFormViewModel(projectImage.ProjectImageID);

            return(ViewDeleteProjectImage(projectImage, viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(ProjectImagePrimaryKey projectImagePrimaryKey, EditViewModel viewModel)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEdit(projectImage, viewModel));
            }
            viewModel.UpdateModel(projectImage, CurrentPerson);
            return(new ModalDialogFormJsonResult());
        }
Ejemplo n.º 5
0
        public ActionResult Edit(ProjectImagePrimaryKey projectImagePrimaryKey, EditViewModel viewModel)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEdit(projectImage, viewModel));
            }
            viewModel.UpdateModel(projectImage, CurrentFirmaSession);
            SetMessageForDisplay("Photo successfully edited.");
            return(new ModalDialogFormJsonResult());
        }
Ejemplo n.º 6
0
        public ActionResult DeleteProjectImage(ProjectImagePrimaryKey projectImagePrimaryKey, ConfirmDialogFormViewModel viewModel)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewDeleteProjectImage(projectImage, viewModel));
            }
            var project = projectImage.Project;

            Project.DeleteProjectImages(new[] { projectImage });
            // reset key photo if needed
            if (projectImage.IsKeyPhoto)
            {
                var firstNonKeyPhoto =
                    project.ProjectImages.FirstOrDefault(x => !x.IsKeyPhoto && x.ProjectImageID != projectImage.ProjectImageID);
                firstNonKeyPhoto?.SetAsKeyPhoto(project.ProjectImages.Except(new[] { firstNonKeyPhoto, projectImage }).ToList());
            }
            return(new ModalDialogFormJsonResult());
        }
Ejemplo n.º 7
0
        public ActionResult DeleteProjectImage(ProjectImagePrimaryKey projectImagePrimaryKey, ConfirmDialogFormViewModel viewModel)
        {
            var projectImage = projectImagePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewDeleteProjectImage(projectImage, viewModel));
            }
            var project = projectImage.Project;

            // will delete the File Resource and the ProjectImage row that references it
            projectImage.FileResourceInfo.DeleteFull(HttpRequestStorage.DatabaseEntities);
            // reset key photo if needed
            if (projectImage.IsKeyPhoto)
            {
                var firstNonKeyPhoto =
                    project.ProjectImages.FirstOrDefault(x => !x.IsKeyPhoto && x.ProjectImageID != projectImage.ProjectImageID);
                firstNonKeyPhoto?.SetAsKeyPhoto(project.ProjectImages.Except(new[] { firstNonKeyPhoto, projectImage }).ToList());
            }
            SetMessageForDisplay("Photo successfully deleted.");
            return(new ModalDialogFormJsonResult());
        }