public override EstateRent Create([FromBody] EstateRent viewModel) { var documentList = new List <Overtech.DataModels.Document.Document>(); long folderId = viewModel.RentFolderHandle.tempFolderId; if (viewModel.RentFolderHandle.folderId.HasValue) { folderId = viewModel.RentFolderHandle.folderId.Value; } if (folderId > 0) { viewModel.ContractFolder = folderId; foreach (var documentHandle in viewModel.RentFolderHandle.documents) { if (documentHandle.tempDocumentId > 0) { var document = _documentService.Read(documentHandle.tempDocumentId); documentList.Add(document); } } } IMapperConfig mapperConfig = estateRentCreatedMapperConfig(); DataModels.Finance.EstateRent dataModel = viewModel.Map <DataModels.Finance.EstateRent, ViewModels.Finance.EstateRent>(mapperConfig); dataModel.DocumentList = documentList; return(_dataService.Create(dataModel).Map <DataModels.Finance.EstateRent, ViewModels.Finance.EstateRent>(mapperConfig)); }
private void updateDataObjectDocument(DataModels.Finance.EstateRent dataObject, IDAL dal) { var documentOperations = new DocumentOperations(dal, this._resolver); var documentType = documentOperations.ReadDocumentTypeByName("Estate Rent"); var tempDocumentTypeId = _parameterReader.ReadSystemParameter <long>("TempDocumentType"); var defaultRepositoryId = _parameterReader.ReadSystemParameter <long>("Default Document Repository Id"); var defaultRepository = dal.Read <Repository>(defaultRepositoryId); foreach (var document in dataObject.DocumentList) { if (document.DocumentType == tempDocumentTypeId) { document.DocumentType = documentType.DocumentTypeId; dal.Update(document); documentOperations.ChangeRepository(document, defaultRepository, false); } } }
public override void Update(EstateRent viewModel) { IMapperConfig mapperConfig = estateRentCreatedMapperConfig(); DataModels.Finance.EstateRent dataModel = viewModel.Map <DataModels.Finance.EstateRent, ViewModels.Finance.EstateRent>(mapperConfig); var documentList = new List <Overtech.DataModels.Document.Document>(); foreach (var documentHandle in viewModel.RentFolderHandle.documents) { if (documentHandle.tempDocumentId > 0) { var document = _documentService.Read(documentHandle.tempDocumentId); documentList.Add(document); } } dataModel.DocumentList = documentList; _dataService.Update(dataModel); }