public override void Update(ContractDraftVersion dataObject) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { var documentOperations = new DocumentOperations(dal, this._resolver); var photoDocumentType = documentOperations.ReadDocumentTypeByName("Rent Contract Draft"); //var defaultRepositoryId = _parameterReader.ReadSystemParameter<long>("Default Document Repository Id"); //var defaultRepository = dal.Read<Repository>(defaultRepositoryId); if (dataObject.DocumentId > 0) { var draftDocument = dal.Read <Document>(dataObject.DocumentId); draftDocument.DocumentType = photoDocumentType.DocumentTypeId; dal.Update(draftDocument); //if (photoDocument.Repository != defaultRepository.RepositoryId) //{ // documentOperations.ChangeRepository(photoDocument, defaultRepository, false); //} } dal.Update(dataObject); dal.CommitTransaction(); } catch { dal.RollbackTransaction(); throw; } } }
public override PricePackage Create(PricePackage dataObject) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { var documentOperations = new DocumentOperations(dal, this._resolver); var photoDocumentType = documentOperations.ReadDocumentTypeByName("Price Package Photo"); //var defaultRepositoryId = _parameterReader.ReadSystemParameter<long>("Default Document Repository Id"); //var defaultRepository = dal.Read<Repository>(defaultRepositoryId); dataObject.PackageId = dal.Create(dataObject); if (dataObject.Image.HasValue) { var photoDocument = dal.Read <Document>(dataObject.Image.Value); photoDocument.DocumentType = photoDocumentType.DocumentTypeId; dal.Update(photoDocument); //documentOperations.ChangeRepository(photoDocument, defaultRepository, false); } dal.CommitTransaction(); return(dataObject); } catch { dal.RollbackTransaction(); throw; } } }
private void updateDataObjectDocument(DataModels.OverStoreMain.OverStoreTask dataObject, IDAL dal) { var documentOperations = new DocumentOperations(dal, this._resolver); var documentType = documentOperations.ReadDocumentTypeByName("Task"); 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); } } }
private long insertPalletPhotoDocument(Overtech.DataModels.Warehouse.GatheringPalletPhoto palletPhoto, IDAL dal) { try { var documentOp = new DocumentOperations(dal, _resolver); var tmpOrganizastion = palletPhoto.Organization; var tmpEvent = palletPhoto.Event; var documentTypeId = documentOp.ReadDocumentTypeByName("Gathering Pallet Photo").DocumentTypeId; var tmpFilename = "palletPhoto_" + palletPhoto.GatheringPalletPhotoId.ToString() + "_" + DateTime.Now.ToShortDateString(); var tmpExtension = "png"; var tmpPhoto = System.Text.Encoding.ASCII.GetBytes(palletPhoto.PhotoContent); var tmpDocumentId = documentOp.CreateDocument(tmpOrganizastion, tmpEvent, null, null, documentTypeId, tmpFilename, tmpExtension, tmpPhoto); return(tmpDocumentId); } catch (Exception ex) { throw ex; } }