Exemplo n.º 1
0
        public static void SaveOrUpdate(AttachmentModelBase baseModel)
        {
            var endpoint = MainContainer.Instance.Resolve <IDbEndPoint>();

            if (baseModel is NoteAttachmentModel noteModel)
            {
                endpoint.SaveComplexObjects(new[] { noteModel });
                //SaveOrUpdate(noteModel);
            }
            else if (baseModel is PhotoAttachmentModel photoModel)
            {
                endpoint.SaveComplexObjects(new[] { photoModel });
                //SaveOrUpdate(photoModel);
            }
            else if (baseModel is DocumentAttachmentModel documentModel)
            {
                endpoint.SaveComplexObjects(new[] { documentModel });
                //SaveOrUpdate(documentModel);
            }
            else if (baseModel is PhotoAlbumAttachmentModel photoAlbumModel)
            {
                endpoint.SaveComplexObjects(new[] { photoAlbumModel });
                //SaveOrUpdate(documentModel);
            }
            else
            {
                throw new InvalidOperationException($"Нельзя сохранить аттач типа '{ baseModel.GetType().Name }'");
            }
        }
Exemplo n.º 2
0
        public static void SetTimestamps(AttachmentModelBase noteModel)
        {
            noteModel.ModificationTime = DateTime.Now;

            if (noteModel.CreationTime == null || noteModel.CreationTime == default(DateTime))
            {
                noteModel.CreationTime = noteModel.ModificationTime;
            }
        }
Exemplo n.º 3
0
        protected AttachmentViewModelBase(AttachmentModelBase attachmentModel, bool isReadonly)
        {
            originalModel = attachmentModel;
            IsReadonly    = isReadonly;

            BeginAcceptingProps();
            Title            = attachmentModel.Title;
            Description      = attachmentModel.Description;
            CreationTime     = attachmentModel.CreationTime;
            ModificationTime = attachmentModel.ModificationTime;
            EndAcceptingProps();

            PropertyChanged += Self_OnPropertyChanged;
        }
        public static AttachmentViewModelBase CreateReadonly(AttachmentModelBase attachmentModel)
        {
            if (attachmentModel is NoteAttachmentModel noteModel)
            {
                return(NoteAttachmentViewModel.CreateReadonly(noteModel));
            }

            if (attachmentModel is PhotoAttachmentModel photoModel)
            {
                return(PhotoAttachmentViewModel.CreateReadonly(photoModel));
            }

            if (attachmentModel is DocumentAttachmentModel documentModel)
            {
                return(DocumentAttachmentViewModel.CreateReadonly(documentModel));
            }

            if (attachmentModel is PhotoAlbumAttachmentModel photoAlbumModel)
            {
                return(new PhotoAlbumAttachmentViewModel(photoAlbumModel, true));
            }

            throw new NotImplementedException();
        }
 protected AttachmentPanelDecoratorBase_NonGeneric PhotoAlbumDecoratorTransform(AttachmentModelBase photoAlbumModel)
 {
     return(new PhotoAlbumPanelDecorator(new PhotoAlbumAttachmentViewModel((PhotoAlbumAttachmentModel)photoAlbumModel, false)));
 }
 protected AttachmentPanelDecoratorBase_NonGeneric DocumentDecoratorTransform(AttachmentModelBase documentModel)
 {
     return(new DocumentPanelDecorator(DocumentAttachmentViewModel.CreateEditable((DocumentAttachmentModel)documentModel)));
 }
 protected AttachmentPanelDecoratorBase_NonGeneric NoteDecoratorTransform(AttachmentModelBase noteModel)
 {
     return(new NotePanelDecorator(NoteAttachmentViewModel.CreateEditable((NoteAttachmentModel)noteModel)));
 }