public async Task <bool> DeleteGearItemAsync(long?gearItemId, CancellationToken ct = default) { GearItemViewModel gearItemToDelete = GearItemConverter.Convert(await this._gearItemRepository.GetByIDAsync(gearItemId, ct)); if (gearItemToDelete == null) { return(false); } if (gearItemToDelete.Images.Count() > 0) { // Delete gearImages from database foreach (GearImageViewModel gearImage in gearItemToDelete.Images) { await this._gearImageRepository.DeleteAsync(gearImage.Id, ct); } } foreach (GearSizeViewModel size in gearItemToDelete.Sizes) { await this._gearSizeRepository.DeleteAsync(size.Id, ct); } return(await this._gearItemRepository.DeleteAsync(gearItemId, ct)); }
public async Task <GearItemViewModel> GetGearItemByIdAsync(long?gearItemId, CancellationToken ct = default) { GearItemViewModel gearitemViewModel = GearItemConverter.Convert(await this._gearItemRepository.GetByIDAsync(gearItemId, ct)); if (gearitemViewModel == null) { return(null); } gearitemViewModel.Images = await GetAllGearImagesByGearItemIdAsync(gearItemId, ct); gearitemViewModel.Sizes = await GetAllGearSizesByGearItemIdAsync(gearItemId, ct); return(gearitemViewModel); }
public async Task <List <GearItemViewModel> > GetAllGearItemsAsync(CancellationToken ct = default) { List <GearItemViewModel> gearItemsViewModel = GearItemConverter.ConvertList(await this._gearItemRepository.GetAllAsync()); return(gearItemsViewModel); }