Пример #1
0
        public async Task <bool> SaveAssignmentDocumentToFile(AssignmentDocumentUploadViewModel model)
        {
            string path = await _documentIOService.SaveAssignmentDocumentAsync(model.FormFile, model.ActivityId);

            if (path.Equals(string.Empty))
            {
                return(false);
            }

            var document = CreateDocument(model.FormFile, model.UserId, path);

            if (!await SaveDocument(document))
            {
                return(false);
            }

            var documentId = await _context.Documents.Where(d => d.Path.Equals(path)).Select(d => d.Id).FirstOrDefaultAsync();

            DocumentsAssignments documentsAssignment = new DocumentsAssignments
            {
                ActivityId = model.ActivityId,
                DocumentId = documentId
            };

            return(await SaveDocumentAssignment(documentsAssignment));
        }
Пример #2
0
        public async Task <IActionResult> AssignmentDocumentUpload(AssignmentDocumentUploadViewModel model)
        {
            var success = await _documentService.SaveAssignmentDocumentToFile(model);

            if (success)
            {
                return(RedirectToAction(@"Details", "Activity", new { Id = model.ActivityId }));
            }
            else
            {
                return(RedirectToAction("Error", "Home"));
            }
        }