public string OpenPublicAccesToFile(int documentId, bool isEditable, ClaimsPrincipal user) { if (!_documentService.IsDocumentExist(documentId)) { throw new Exception("Document is not exist"); } if (!_userService.IsUserTheOwnerOfTheDocument(user, documentId)) { throw new UnauthorizedAccessException("User is not the owner of the file"); } DocumentLinkView docLink = _documentLinkService.Get(documentId); if (docLink != null) { if (docLink.IsEditable == isEditable) { return(docLink.Link); } docLink.IsEditable = isEditable; _documentLinkService.Update(docLink); return(docLink.Link); } string guid = Guid.NewGuid().ToString(); _documentLinkService.Create(new DocumentLinkView { Id = documentId, IsEditable = isEditable, Link = guid }); return(guid); }
public IActionResult ConfirmDelete(int?id) { if (id != null) { DocumentLinkView documentLink = service.Get(id); if (documentLink != null) { return(View(documentLink)); } } return(NotFound()); }
public DocumentView GetPublicSharedDocument(string guid, ClaimsPrincipal user, out bool isEditable) { DocumentLinkView docLink = _documentLinkService.GetAll().FirstOrDefault(p => p.Link == guid); if (docLink == null) { throw new Exception("Id not found"); } DocumentView doc = _documentService.Get(docLink.Id); isEditable = docLink.IsEditable; return(doc); }
public IActionResult Delete(int?id) { if (id != null) { DocumentLinkView documentLink = service.Get(id); if (documentLink != null) { service.Delete(id); return(RedirectToAction("Index")); } } return(NotFound()); }
public DocumentLinkJsonView GetPublicAccessLink(int documentId) { DocumentLinkView docLink = _sharingService.GetPublicAccessLink(documentId, User); if (docLink == null) { return(new DocumentLinkJsonView { Link = "", IsEditable = false }); } return(new DocumentLinkJsonView { Link = Request.Host.Value + "/Share/Get?id=" + docLink.Link + "&adm=pub", IsEditable = docLink.IsEditable }); }
public void ClosePublicAccesToFile(int documentId, ClaimsPrincipal user) { if (!_userService.IsUserTheOwnerOfTheDocument(user, documentId)) { throw new UnauthorizedAccessException("User is not the owner of the file"); } DocumentLinkView documentLink = _documentLinkService.Get(documentId); if (documentLink != null) { _documentLinkService.Delete(documentId); } }
public IActionResult Edit(DocumentLinkView documentLink) { service.Update(documentLink); return(RedirectToAction("Index")); }
public void Update(DocumentLinkView documentLinkView) { DocumentLink documentLink = mapper.Map <DocumentLinkView, DocumentLink> (documentLinkView); repo.Update(documentLink); }