public SharedUnitIndex GetSharedUnitIndex(SharedUnitIndexId sharedUnitIndexId) { var unitIndex = unitIndexService.GetBy(new PMSAdminModel.UnitIndices.AbstractUnitIndexId(sharedUnitIndexId.Id)); var sharedUnit = new SharedUnitIndex(new SharedUnitIndexId(unitIndex.Id.Id), unitIndex.Name, unitIndex.DictionaryName); return(sharedUnit); }
public static void CreateUnitIndex(IUnitIndexRepository unitIndexRepository, PMSAdmin.Domain.Model.UnitIndices.UnitIndex adminUnitIndex, UnitIndexGroup unitIndexGroup, bool isInquireable, Dictionary <PMSAdmin.Domain.Model.CustomFieldTypes.CustomFieldType, string> customFieldsDictionary) { var sharedUnitIndex = new SharedUnitIndex(new SharedUnitIndexId(adminUnitIndex.Id.Id), adminUnitIndex.Name, adminUnitIndex.DictionaryName); var unitIndex = new UnitIndex(unitIndexRepository.GetNextId(), Period, sharedUnitIndex, unitIndexGroup, isInquireable); var sharedCustomFieldsDic = customFieldsDictionary.ToDictionary( c => new SharedUnitIndexCustomField(new SharedUnitIndexCustomFieldId(c.Key.Id.Id), c.Key.Name, c.Key.DictionaryName, c.Key.MinValue, c.Key.MaxValue), c => c.Value); unitIndex.UpdateCustomFields(sharedCustomFieldsDic); unitIndexRepository.Add(unitIndex); unitIndices.Add(unitIndex); }