示例#1
0
        public override async Task <bool> Delete(int id)
        {
            if (id <= 0)
            {
                throw new InvalidOperationException();
            }

            IReadOnlyCollection <HotelEquipmentType> toDelete =
                new HotelEquipmentType[0];

            using (var cp = ContextProviderFactory.Create())
            {
                toDelete =
                    await cp.GetTable <HotelEquipmentType>()
                    .Where(t => t.HotelId == id)
                    .ToArrayAsync();
            }

            foreach (var restaurantCuisineTypes in toDelete)
            {
                await _hotelEquipmentTypesService.Delete(restaurantCuisineTypes.HotelId,
                                                         restaurantCuisineTypes.EquipmentTypeId);
            }

            IReadOnlyCollection <HotelServiceType> toDelete2 =
                new HotelServiceType[0];

            using (var cp = ContextProviderFactory.Create())
            {
                toDelete2 =
                    await cp.GetTable <HotelServiceType>()
                    .Where(t => t.HotelId == id)
                    .ToArrayAsync();
            }

            foreach (var restaurantDenyType in toDelete2)
            {
                await _hotelServiceTypesService.Delete(restaurantDenyType.HotelId, restaurantDenyType.ServiceTypeId);
            }

            await base.Delete(id);

            return(true);
        }
示例#2
0
        public async Task <IActionResult> DeleteServiceTypeById(int hotelId, int[] serviceTypeIds)
        {
            if (hotelId <= 0)
            {
                return(BadRequest());
            }

            int count = 0;

            foreach (var serviceTypeId in serviceTypeIds)
            {
                var res =
                    await _hotelServiceTypesService.Delete(hotelId, serviceTypeId);

                count += res ? 1 : 0;
            }

            return(Ok(count == serviceTypeIds.Length));
        }