private Task <object> UploadSingleFile(object userId, object articleId, HttpPostedFileBase file) { if (userId == null) { throw new ArgumentNullException(nameof(userId)); } if (articleId == null) { throw new ArgumentNullException(nameof(articleId)); } if (file == null || file.ContentLength < 1) { throw new NullOrEmptyFileException(); } var document = new DocumentServiceModel { FileName = Path.GetFileNameWithoutExtension(file.FileName).Trim('.'), FileExtension = Path.GetExtension(file.FileName).Trim('.'), ContentLength = file.ContentLength, ContentType = file.ContentType }; var task = this.service.Create(userId, articleId, document, file.InputStream); return(task); }
private async Task <object> WriteDocument(FileModel model, string userId, int articleId, XmlDocument document) { using (var stream = document.OuterXml.ToStream()) { string comment = this.commandsInformation .Values .FirstOrDefault(i => i.Name == model.CommandId) .Description; var documentMetadata = new DocumentServiceModel { Comment = comment, ContentLength = stream.Length, ContentType = ContentTypes.Xml, FileExtension = FileConstants.XmlFileExtension, FileName = model.FileName }; var result = await this.service.Create(userId, articleId, documentMetadata, stream); stream.Close(); return(result); } }
public async Task <JsonResult> SaveXml(string id, string content) { if (string.IsNullOrWhiteSpace(id)) { return(this.InvalidDocumentIdJsonResult()); } var userId = this.User.Identity.GetUserId(); var document = new DocumentServiceModel { Id = id, ContentType = ContentTypes.Xml }; await this.presenter.SaveXml(userId, this.fakeArticleId, document, content); return(this.DocumentSavedSuccessfullyJsonResult()); }
public IActionResult Edit(int id) { DocumentServiceModel document = this.documentsService.GetById(id); if (document.Name == null) { return(this.BadRequest()); } var model = new DocumentInputModel { Id = document.Id, DocumentName = document.Name, DocumentDescription = document.Description, }; return(this.View(model)); }
public IActionResult Details(int id) { DocumentServiceModel document = this.documentsService.GetById(id); if (document.Name == null) { return(this.BadRequest()); } var model = new DocumentDetailsViewModel { Id = document.Id, Name = document.Name, Description = document.Description, // TODO: Add services table }; return(this.View(model)); }