Пример #1
0
        public ServiceResponse <Data.Models.Document> UpdateDocument(Data.Models.Document document)
        {
            try
            {
                _db.Documents.Update(document);
                _db.SaveChanges();

                return(new ServiceResponse <Data.Models.Document>
                {
                    IsSuccess = true,
                    Message = "New Document Updated",
                    Time = DateTime.UtcNow,
                    Data = document
                });
            }
            catch (Exception e)
            {
                return(new ServiceResponse <Data.Models.Document>
                {
                    IsSuccess = false,
                    Message = e.StackTrace,
                    Time = DateTime.UtcNow,
                    Data = null
                });
            }
        }
Пример #2
0
 public void UpdateTags(int DocumentId, string Tags)
 {
     Data.Models.Document existingDocument = _documentRepository.Table.FirstOrDefault(w => w.Id == DocumentId);
     if (existingDocument != null)
     {
         existingDocument.Tags = Tags;
         _documentRepository.Update(existingDocument);
     }
 }
Пример #3
0
        public Task <Data.Models.Document> GetDocumentById(Data.Models.Document document)
        {
            const string command = "select * from Document WHERE DocId = @DocId and RiskAssessmentID = @RiskAssessmentID;";

            return(_sqlConnection.QuerySingleOrDefaultAsync <Data.Models.Document>(command, new
            {
                document.DocId,
                document.RiskAssessmentID
            }));
        }
Пример #4
0
        public Task <OperationResult> RemoveFromDocumentAsync(Data.Models.Document document)
        {
            const string command = "DELETE FROM dbo.Document WHERE DocId = @DocId and RiskAssessmentID = @RiskAssessmentID;";

            int rowsDeleted = Task.Run(() => _sqlConnection.ExecuteAsync(command, new
            {
                document.DocId,
                document.RiskAssessmentID
            })).Result;

            return(Task.FromResult(rowsDeleted.Equals(1) ? OperationResult.Success : OperationResult.Failed(new OperationResultError
            {
                Code = string.Empty,
                Description = $"The file with name {document.DocumentName} could not be deleted from the dbo.Document table."
            })));
        }
Пример #5
0
        public Task <OperationResult> AddToDocumentAsync(Data.Models.Document document)
        {
            const string command = "INSERT INTO [dbo].[Document]([RiskAssessmentID],[DocumentName],[FileName],[FTPLink],[DocumentGUID]) " +
                                   "VALUES (@RiskAssessmentID,@DocumentName,@FileName,@FTPLink,@DocumentGUID);";

            int rowsAdded = Task.Run(() => _sqlConnection.ExecuteAsync(command, new
            {
                document.RiskAssessmentID,
                document.DocumentName,
                document.FileName,
                document.FTPLink,
                document.DocumentGUID
            })).Result;

            return(Task.FromResult(rowsAdded.Equals(1)
                ? OperationResult.Success
                : OperationResult.Failed(new OperationResultError
            {
                Code = string.Empty,
                Description =
                    $"The file with name {document.DocumentName} could not be inserted from the dbo.Document table."
            })));
        }
Пример #6
0
 public JsonNetResult GetTagsById(int DocumentId)
 {
     Data.Models.Document existingDocument = this._documentService.GetForId(DocumentId);
     return(JsonNet(new { Tags = existingDocument.Tags }, JsonRequestBehavior.AllowGet));
 }