public async Task <Int32> CreateAsync(Offer offer, CancellationTokenSource token) { B2COffer newOffer = offer.AdapterOffer(); newOffer.IsActive = true; var result = await Repository.CreateAsync(newOffer, token); if (offer.Image != null) { await ServiceImage.CreateAsync(offer.Image, offer.IdProduct, result, token); } return(result); }
public async Task <bool> Update(Offer offer, CancellationTokenSource token) { bool exists = await Repository.ExistAsync(offer.Id, token); if (exists) { B2COffer updateOffer = offer.AdapterOffer(); var result = await Repository.UpdateAsync(updateOffer, token); if (offer.Image != null) { await ServiceImage.UpdateAsync(offer.Image, token); } return(result); } else { string msg = String.Format(MessagesApplication.NotFoundCode, offer.Id); throw new BussinesException(msg, null); } }