/// <summary> /// Aggiunge una nuova DocumentUnitAggregate /// </summary> /// <param name="aggregate"></param> /// <returns>Ritorna l'aggregato aggiunto</returns> public DocumentUnitAggregate UdsAddDocumentUnitAggregate(DocumentUnitAggregate aggregate) { try { if (aggregate == null) { throw DocumentUnitAggregateException.NotFound(); } var entity = new Model.DocumentUnitAggregate { IdAggregate = Guid.NewGuid(), AggregationType = aggregate.AggregationType, CloseDate = aggregate.CloseDate, PreservationDate = aggregate.PreservationDate, XmlFascicle = aggregate.XmlFascicle }; this.db.DocumentUnitAggregate.AddObject(entity); if (requireSave) { this.db.SaveChanges(); } var ret = entity.Convert(0, 3); return(ret); } finally { Dispose(); } }
private Model.DocumentUnitAggregate UdsGetDocumentUnitAggregateModel(Guid idAggregate, out bool isReadOnly, out bool isPreserved) { isReadOnly = false; isPreserved = false; var aggregate = this.db.DocumentUnitAggregate .Include("DocumentUnit") .SingleOrDefault(p => p.IdAggregate == idAggregate); if (aggregate == null) { throw DocumentUnitAggregateException.NotFound(); } isReadOnly = (aggregate.CloseDate != null || aggregate.PreservationDate != null); isPreserved = aggregate.PreservationDate != null; return(aggregate); }