Exemplo n.º 1
0
        public ActionResult <IEnumerable <DocResponse> > GetAllAttachedByMarkId(
            int markId)
        {
            var docs = _service.GetAllAttachedByMarkId(markId);

            return(Ok(_mapper.Map <IEnumerable <DocResponse> >(docs)));
        }
Exemplo n.º 2
0
        public void GetAllAttachedByMarkId_ShouldReturnAttached()
        {
            // Arrange
            int markId         = _rnd.Next(1, _maxMarkId);
            int sheetDocTypeId = 1;

            // Act
            var returnedAttachedDocs = _service.GetAllAttachedByMarkId(markId);

            // Assert
            Assert.Equal(_docs.Where(
                             v => v.Mark.Id == markId && v.Type.Id != sheetDocTypeId), returnedAttachedDocs);
        }
Exemplo n.º 3
0
        public void PopulateDocument(int markId, MemoryStream memory)
        {
            var mark = _markRepo.GetById(markId);

            if (mark == null)
            {
                throw new ArgumentNullException(nameof(mark));
            }
            var subnode = mark.Subnode;
            var node    = subnode.Node;
            var project = node.Project;

            var sheets                = _docService.GetAllSheetsByMarkId(markId).ToList();
            var docs                  = _docService.GetAllAttachedByMarkId(markId).ToList();
            var attachedDocs          = _attachedDocRepo.GetAllByMarkId(markId).ToList();
            var additionalWork        = _additionalWorkService.GetAllByMarkId(markId).ToList();
            var constructions         = _constructionRepo.GetAllByMarkId(markId).ToList();
            var standardConstructions = _standardConstructionRepo.GetAllByMarkId(markId).ToList();

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true))
            {
                var markName = MarkHelper.MakeMarkName(
                    project.BaseSeries, node.Code, subnode.Code, mark.Code);
                (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName(
                    project.Name, node.Name, subnode.Name, mark.Name);

                Word.ReplaceText(wordDoc, "A", markName);
                Word.ReplaceText(wordDoc, "B", complexName);
                Word.ReplaceText(wordDoc, "C", objectName);
                Word.ReplaceText(wordDoc, "D", mark.Subnode.Node.ChiefEngineer.Name);
                Word.ReplaceText(wordDoc, "E", mark.GroupLeader.Name);
                Word.ReplaceText(
                    wordDoc, "F", mark.IssueDate.GetValueOrDefault().ToString("dd.MM.yyyy"));
                Word.ReplaceText(wordDoc, "G", FindWeight(constructions, standardConstructions).ToStringWithComma());
                AppendToSheetsTable(wordDoc, sheets);
                AppendToDocsTable(wordDoc, docs);
                AppendToAttachedDocsTable(wordDoc, attachedDocs);
                AppendToAdditionalWorkTable(wordDoc, additionalWork);

                Word.AppendToMainSmallFooterTable(wordDoc, markName);
                Word.AppendToSmallFooterTable(wordDoc, markName);
            }
        }