示例#1
0
        public void Update(
            int id,
            SpecificationUpdateRequest specification)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }
            var foundSpecification = _repository.GetById(id);

            if (foundSpecification == null)
            {
                throw new ArgumentNullException(nameof(foundSpecification));
            }

            if (specification.IsCurrent == true)
            {
                var spec = _repository.GetCurrentByMarkId(foundSpecification.Mark.Id);
                spec.IsCurrent = false;
                _repository.Update(spec);
                foundSpecification.IsCurrent = true;
            }
            if (specification.Note != null)
            {
                foundSpecification.Note = specification.Note;
            }
            _repository.Update(foundSpecification);

            var foundMark = _markRepo.GetById(foundSpecification.Mark.Id);

            foundMark.EditedDate = DateTime.Now;
            _markRepo.Update(foundMark);
        }
示例#2
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 departmentHead = _employeeRepo.GetByDepartmentIdAndPosition(
                mark.Department.Id, _appSettings.DepartmentHeadPosId);

            if (departmentHead == null)
            {
                departmentHead = _employeeRepo.GetByDepartmentIdAndPosition(
                    mark.Department.Id, _appSettings.ActingDepartmentHeadPosId);
            }
            if (departmentHead == null)
            {
                departmentHead = _employeeRepo.GetByDepartmentIdAndPosition(
                    mark.Department.Id, _appSettings.DeputyDepartmentHeadPosId);
            }
            if (departmentHead == null)
            {
                departmentHead = _employeeRepo.GetByDepartmentIdAndPosition(
                    mark.Department.Id, _appSettings.ActingDeputyDepartmentHeadPosId);
            }
            if (departmentHead == null)
            {
                throw new ConflictException();
            }

            var currentSpec = _specificationRepo.GetCurrentByMarkId(markId);

            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);

                AppendToTable(wordDoc, currentSpec.Id);
                Word.AppendToMediumFooterTable(
                    wordDoc,
                    markName,
                    complexName,
                    objectName,
                    mark,
                    departmentHead);
                Word.AppendToSmallFooterTable(wordDoc, markName);
            }
        }