Example #1
0
        public async void UnassignLocatablePromoAsync(int locatableId, int promoId)
        {
            LocatablePromo locatablePromo = await FindByLocatableIdAndPromoId(locatableId, promoId);

            if (locatablePromo == null)
            {
                Remove(locatablePromo);
            }
        }
Example #2
0
        public async Task AssignLocatablePromo(int locatableId, int promoId)
        {
            LocatablePromo locatablePromo = await FindByLocatableIdAndPromoId(locatableId, promoId);

            if (locatablePromo == null)
            {
                locatablePromo = new LocatablePromo {
                    LocatableId = locatableId, PromoId = promoId
                };
                await AddAsync(locatablePromo);
            }
        }
        public async Task <LocatablePromoResponse> UnassignLocatablePromoAsync(int locatableId, int promoId)
        {
            try
            {
                LocatablePromo locatablePromo = await _locatablePromoRepository.FindByLocatableIdAndPromoId(locatableId, promoId);

                _locatablePromoRepository.Remove(locatablePromo);
                await _unitOfWork.CompleteAsync();

                return(new LocatablePromoResponse(locatablePromo));
            }
            catch (Exception ex)
            {
                return(new LocatablePromoResponse($"An error ocurred while unassigning Promo to Locatable: {ex.Message}"));
            }
        }
Example #4
0
 public void Remove(LocatablePromo locatablePromo)
 {
     _context.Remove(locatablePromo);
 }
Example #5
0
 public async Task AddAsync(LocatablePromo locatablePromo)
 {
     await _context.LocatablePromos.AddAsync(locatablePromo);
 }