public AdminLookupItemValueModel(SystemLookupItemValue entity) { Id = entity.Id; CanonicalName = entity.CanonicalName; DisplayName = entity.DisplayName; Abbreviation = entity.Abbreviation; }
public async Task <SystemLookupItemValueModel> GetItem(string name, string id) { SystemLookupItemValue entity = await _systemLookupItemManager.GetItemAsync(name, id); var model = new SystemLookupItemValueModel(entity); return(model); }
public async Task <SystemLookupItemValue> GetItemAsync(string groupName, string id) { SystemLookupItemValue item = null; var group = await GetItemAsync(groupName); if (group != null) { item = await GetItem(group.Values, id); } return(item); }
public async Task <SystemLookupItemModel> DeleteItem(string groupKey, string itemKey) { var groupKeyIsGuid = Guid.TryParse(groupKey, out var groupId); var itemKeyIsGuid = Guid.TryParse(itemKey, out var itemId); var group = new SystemLookupItem(); if (groupKeyIsGuid) { group = await _systemLookupItemManager.GetItemAsync(groupId); if (group == null) { throw new SystemLookupItemNotFoundException(string.Format("System LookupItem group ID '{0}', item ID '{1}' deleted successfully.", groupId, itemId)); } } else { group = await _systemLookupItemManager.GetItemAsync(groupKey); if (group == null) { throw new SystemLookupItemNotFoundException(string.Format("System LookupItem group '{0}', item ID '{1}' deleted successfully.", groupKey, itemId)); } } var item = new SystemLookupItemValue(); if (itemKeyIsGuid) { item = group.Values.SingleOrDefault(x => x.Id == itemKey); if (item == null) { throw new SystemLookupItemNotFoundException(string.Format("System LookupItem group ID '{0}', item '{1}' deleted successfully.", groupId, itemKey)); } } else { item = group.Values.SingleOrDefault(x => x.CanonicalName == itemKey); if (group == null) { throw new SystemLookupItemNotFoundException(string.Format("System LookupItem group '{0}', item '{1}' deleted successfully.", groupKey, itemKey)); } } item.Enabled = false; var model = new SystemLookupItemModel(group); return(model); }
private async Task <IEnumerable <SystemLookupItemValue> > ConvertModelToEntity(List <SystemLookupItemValueModel> model) { List <SystemLookupItemValue> lookupItemsEntity = new List <SystemLookupItemValue>(); foreach (SystemLookupItemValueModel lookupItemValueModel in model) { SystemLookupItemValue lookupItemEntity = new SystemLookupItemValue() { Id = Guid.NewGuid().ToString(), CanonicalName = lookupItemValueModel.CanonicalName, Abbreviation = lookupItemValueModel.Abbreviation, }; lookupItemsEntity.Add(lookupItemEntity); } return(lookupItemsEntity); }
public async Task <SystemLookupItemValue> GetItem(string itemName, string id) { SystemLookupItemValue results = await _systemLookupItemManager.GetItemAsync(itemName, id); return(results); }