public bool Delete(Methodology entity) { Contract.Requires(entity != null); Contract.Requires(entity.Id >= 0); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository<Methodology> repo = uow.GetRepository<Methodology>(); entity = repo.Reload(entity); //relation to DataContainer is managed by the other end repo.Delete(entity); uow.Commit(); } // if any problem was detected during the commit, an exception will be thrown! return (true); }
public Methodology Create(string appliedStandards, string tools, string tolerance, string procedure) { Contract.Requires(!string.IsNullOrWhiteSpace(procedure)); Contract.Ensures(Contract.Result<Methodology>() != null && Contract.Result<Methodology>().Id >= 0); Methodology u = new Methodology() { AppliedStandards = appliedStandards, Tools = tools, Tolerance = tolerance, Procedure = procedure, }; using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository<Methodology> repo = uow.GetRepository<Methodology>(); repo.Put(u); uow.Commit(); } return (u); }
public DataAttribute CreateDataAttribute(string shortName, string name, string description, bool isMultiValue, bool isBuiltIn, string scope, MeasurementScale measurementScale, DataContainerType containerType, string entitySelectionPredicate, DataType dataType, Unit unit, Methodology methodology, Classifier classifier, ICollection<AggregateFunction> functions, ICollection<GlobalizationInfo> globalizationInfos, ICollection<Constraint> constraints, ICollection<ExtendedProperty> extendedProperies ) { Contract.Requires(!string.IsNullOrWhiteSpace(shortName)); Contract.Requires(dataType != null && dataType.Id >= 0); Contract.Requires(unit != null && unit.Id >= 0); Contract.Ensures(Contract.Result<DataAttribute>() != null && Contract.Result<DataAttribute>().Id >= 0); DataAttribute e = new DataAttribute() { ShortName = shortName, Name = name, Description = description, IsMultiValue = isMultiValue, IsBuiltIn = isBuiltIn, Scope = scope, MeasurementScale = measurementScale, ContainerType = containerType, EntitySelectionPredicate = entitySelectionPredicate, DataType = dataType, Unit = unit, Methodology = methodology, AggregateFunctions = functions, GlobalizationInfos = globalizationInfos, Constraints = constraints, ExtendedProperties = extendedProperies, }; if (classifier != null && classifier.Id > 0) e.Classification = classifier; using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository<DataAttribute> repo = uow.GetRepository<DataAttribute>(); repo.Put(e); uow.Commit(); } return (e); }
public Methodology Update(Methodology entity) { Contract.Requires(entity != null, "provided entity can not be null"); Contract.Requires(entity.Id >= 0, "provided entity must have a permant ID"); Contract.Ensures(Contract.Result<Methodology>() != null && Contract.Result<Methodology>().Id >= 0, "No entity is persisted!"); using (IUnitOfWork uow = entity.GetUnitOfWork()) { IRepository<Methodology> repo = uow.GetRepository<Methodology>(); repo.Put(entity); // Merge is required here!!!! uow.Commit(); } return (entity); }