public DeliveryNoteItemModel GetItem(Guid itemId) { var subscriberId = UserContext.Current.SubscriberId; var item = _itemSearchRepository.GetEntity(subscriberId, itemId); if (item == null) { return(null); } var properties = _itemPropertyValueSearchRepository.GetPropertyValues(UserContext.Current.SubscriberId, item.Id); var model = Mapper.Map <DeliveryNoteItemModel>(item); model.Properties = properties; return(model); }
private List <DeliveryNoteItemModel> GetItems(Guid noteId) { var subscriberId = UserContext.Current.SubscriberId; var items = _itemSearchRepository.GetEntities(subscriberId, s => s.DeliveryNoteId == noteId); if (items.Any()) { var ids = items.Select(s => s.Id); var properties = _itemPropertyValueSearchRepository.GetPropertyValues(UserContext.Current.SubscriberId, ids); return(items.Select(item => { var model = Mapper.Map <DeliveryNoteItemModel>(item); var ps = properties.FirstOrDefault(s => s.Key == item.Id); model.Properties = ps == null ? new List <DeliveryNoteItemPropertyValueModel>() : ps.ToList(); return model; }).ToList()); } return(new List <DeliveryNoteItemModel>()); }