public async Task <DelegateOffer> CreateDelegateOffer(CreateDelegateOfferModel creatDelegateOfferModel, string jwt) { if (string.IsNullOrEmpty(creatDelegateOfferModel.Title) || string.IsNullOrEmpty(creatDelegateOfferModel.Description)) { throw new EmptyFieldException(); } var delegateOffer = new DelegateOffer { Id = Guid.NewGuid(), Provider = creatDelegateOfferModel.Provider, Title = creatDelegateOfferModel.Title, Description = creatDelegateOfferModel.Description, Region = creatDelegateOfferModel.Region, LiskPerMonth = creatDelegateOfferModel.LiskPerMonth, AvailableForInMonths = creatDelegateOfferModel.AvailableForInMonths }; var id = _jwtIdClaimReaderHelper.getUserIdFromToken(jwt); if (delegateOffer.Provider.Id != id) { throw new NotAuthenticatedException(); } return(await _delegateRepository.CreateDelegateOffer(delegateOffer)); }
public async Task CreateProduct() { var product = new DelegateOffer { Id = Guid.NewGuid(), Title = "Title Text", Description = "Description Text" }; var result = await _delegateRepository.CreateDelegateOffer(product); Assert.NotNull(result); Assert.Equal(product, result); }