Пример #1
0
        public SelectGoogleDocument(Action <string, string, DialogIcon> showDialogAction, IGoogleDocumentsService documentsService)
        {
            this.Icon = PackageRes.ResxGenIcon.GetImageSource();

            _showDialogAction = showDialogAction;
            _documentsService = documentsService;

            ViewModel        = new DocumentsVm();
            this.DataContext = ViewModel;

            InitializeComponent();
        }
        public async Task <DocumentsVm> GetByUserId(long documentid)
        {
            var document = await _context.Documents.FindAsync(documentid);

            var user = await(from u in _context.Users
                             join d in _context.Documents on u.Id equals d.UserID
                             select d.User.UserName).ToListAsync();

            var documentvm = new DocumentsVm()
            {
                ID       = document.ID,
                UserName = document.User.UserName,
                Caption  = document.Caption,
            };

            return(documentvm);
        }
        public async Task <DocumentsVm> GetById(long documentId)
        {
            var document = await _context.Documents.FindAsync(documentId);

            if (document == null)
            {
                throw new WebEnterpriseException($"Cannot find an document with id {document}");
            }

            var viewModel = new DocumentsVm()
            {
                Caption      = document.Caption,
                CreateOn     = document.CreateOn,
                FileSize     = document.FileSize,
                ID           = document.ID,
                DocumentPath = document.DocumentPath,
                UserID       = document.UserID,
            };

            return(viewModel);
        }