public async void UnassignLocatablePromoAsync(int locatableId, int promoId) { LocatablePromo locatablePromo = await FindByLocatableIdAndPromoId(locatableId, promoId); if (locatablePromo == null) { Remove(locatablePromo); } }
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}")); } }
public void Remove(LocatablePromo locatablePromo) { _context.Remove(locatablePromo); }
public async Task AddAsync(LocatablePromo locatablePromo) { await _context.LocatablePromos.AddAsync(locatablePromo); }