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 AbstractUnitIndexId GetUnitIndexIdBy(Period period, SharedUnitIndexId sharedUnitIndexId) { using (var tr = new TransactionScope()) { var res = unitIndexRep.GetUnitIndexIdBy(period, sharedUnitIndexId); tr.Complete(); return(res); } }
public IList <SharedUnitIndexCustomField> GetSharedUnitIndexCustomField(SharedUnitIndexId sharedUnitIndexId, List <SharedUnitIndexCustomFieldId> fieldIdList) { using (var tr = new TransactionScope()) { var res = pmsAdminService.GetSharedCutomFieldListForUnitIndex(sharedUnitIndexId, fieldIdList); tr.Complete(); return(res); } }
public List <SharedUnitIndexCustomField> GetSharedCutomFieldListForUnitIndex(SharedUnitIndexId sharedUnitIndexId, IList <SharedUnitIndexCustomFieldId> customFieldIdList) { var isValid = unitIndexService.IsValidCustomFieldIdList(new PMSAdminModel.UnitIndices.AbstractUnitIndexId(sharedUnitIndexId.Id), customFieldIdList.Select(c => new CustomFieldTypeId(c.Id)) .ToList()); if (!isValid) { throw new ArgumentException("Invalid unit customFieldIdList"); } var res = customFieldService.GetBy(customFieldIdList.Select(c => new CustomFieldTypeId(c.Id)).ToList()); return (res.Select( r => new SharedUnitIndexCustomField(new SharedUnitIndexCustomFieldId(r.Id.Id), r.Name, r.DictionaryName, r.MinValue, r.MaxValue)) .ToList()); }
public AbstractUnitIndexId GetUnitIndexIdBy(Period period, SharedUnitIndexId sharedUnitIndexId) { return(rep.Single <UnitIndex>(j => j.PeriodId == period.Id && j.SharedUnitIndexId.Id == sharedUnitIndexId.Id).Id); }
public UnitIndex AddUnitIndex(PeriodId periodId, AbstractUnitIndexId groupId, SharedUnitIndexId unitIndexId, IDictionary <SharedUnitIndexCustomFieldId, string> customFieldValues, bool isInquireable, int calculationOrder, long calculationLevel) { try { using (var tr = new TransactionScope()) { var period = periodRep.GetById(periodId); var sharedUnit = pmsAdminService.GetSharedUnitIndex(unitIndexId); var id = unitIndexRep.GetNextId(); if (groupId == null) { throw new ArgumentException("groupId is null"); } var group = unitIndexRep.GetUnitIndexGroupById(groupId); var unitIndex = new UnitIndex(id, period, sharedUnit, group, isInquireable, calculationLevel, calculationOrder); var validateCustomFldValues = getSharedUnitIndexCustomFields(unitIndexId, customFieldValues); unitIndex.UpdateCustomFields(validateCustomFldValues); unitIndexRep.Add(unitIndex); tr.Complete(); return(unitIndex); } } catch (Exception exp) { var res = unitIndexRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
private Dictionary <SharedUnitIndexCustomField, string> getSharedUnitIndexCustomFields(SharedUnitIndexId jabIndexId, IDictionary <SharedUnitIndexCustomFieldId, string> fieldIdValues) { var validateCustomFieldValues = new Dictionary <SharedUnitIndexCustomField, string>(); var validateCustomFields = pmsAdminService.GetSharedCutomFieldListForUnitIndex(jabIndexId, new List <SharedUnitIndexCustomFieldId>(fieldIdValues.Keys)); foreach (var itm in validateCustomFields) { validateCustomFieldValues.Add(itm, fieldIdValues[itm.Id]); } return(validateCustomFieldValues); }