public async Task UpdateDelegateOffer() { //Arrange var product1 = new DelegateOffer { Id = Guid.NewGuid(), Title = "Title1", Description = "Description1" }; var product2 = new DelegateOffer { Id = Guid.NewGuid(), Title = "Title2", Description = "Description2" }; await _delegateRepository.CreateDelegateOffer(product1); await _delegateRepository.CreateDelegateOffer(product2); //Act product1.Title = "Title1Edited"; await _delegateRepository.UpdateDelegateOffer(product1.Id, product1); var result = await _delegateRepository.GetDelegateOffer(product1.Id); //Assert Assert.NotNull(result); Assert.Equal(product1.Title, result.Title); }
public async Task <DelegateOffer> UpdateDelegateOffer(Guid id, UpdateDelegateOfferModel updateDelegateOfferModel, string jwt) { if (string.IsNullOrEmpty(updateDelegateOfferModel.Title) || string.IsNullOrEmpty(updateDelegateOfferModel.Description)) { throw new EmptyFieldException(); } var delegateOffer = await GetDelegateOffer(id); if (delegateOffer.Provider.Id != _jwtIdClaimReaderHelper.getUserIdFromToken(jwt)) { throw new NotAuthenticatedException(); } delegateOffer.Id = id; delegateOffer.Title = updateDelegateOfferModel.Title; delegateOffer.Description = updateDelegateOfferModel.Description; delegateOffer.Region = updateDelegateOfferModel.Region; delegateOffer.LiskPerMonth = updateDelegateOfferModel.LiskPerMonth; delegateOffer.AvailableForInMonths = updateDelegateOfferModel.AvailableForInMonths; return(await _delegateRepository.UpdateDelegateOffer(id, delegateOffer)); }