public ICollection <PhotoListModel> GetPhotosByItemTag(ItemTagModel itemTagModel, int pageIndex, int pageSize = IoC.IoC.PageSize) { return(Mapper.PhotoEntitiesToPhotoListModels(_dataContext.Photos .Where(x => x.Tags.Contains(Mapper.ItemTagModelToItemTagEntity(itemTagModel))) .Skip((pageIndex - 1) * pageSize) .Take(pageSize) .ToList())); }
public static ItemTagEntity ItemTagModelToItemTagEntity(ItemTagModel itemTagModel) { return(new ItemTagEntity { Id = itemTagModel.Id, ItemId = itemTagModel.ItemId, XPosition = itemTagModel.XPosition, YPosition = itemTagModel.YPosition, }); }
public async Task AttachTagsToItemAsync(IEnumerable <string> values, int itemId) { await ClearItemTags(itemId); var itemTags = new List <ItemTagModel>(); var newTags = await MaterializeTagsByValues(values); foreach (var tag in newTags) { var itemTag = new ItemTagModel { ItemId = itemId, TagId = tag.Id }; itemTags.Add(itemTag); } await itemTagCrudService.CreateRangeAsync(itemTags); }