public async Task DeleteConsent(GrowerConsentFormModel consent) { await Task.Run(() => { if (_consents.Contains(consent.GrowerConsentCommonId)) { _consents.Remove(consent.GrowerConsentCommonId); } return(null); }); }
public async Task <GrowerConsentFormModel> PostConsent(GrowerConsentFormModel consent) { var task = await Task.Run(() => { if (!_consents.Contains(consent.GrowerConsentCommonId)) { _consents[consent.GrowerConsentCommonId] = consent; return(_consents[consent.GrowerConsentCommonId] as GrowerConsentFormModel); } return(null); }); return(task); }
public async Task <GrowerConsentFormModel> UpdateConsent(string id, GrowerConsentFormModel consent) { var task = await Task.Run(() => { if (_consents.Contains(id)) { _consents[id] = consent; return(_consents[id] as GrowerConsentFormModel); } return(null); }); return(task); }
public async Task CreateConsent() { consentData = new CdipData(); service = new GrowerConsentService(consentData, confirmationTokenService); var id = Guid.NewGuid().ToString(); var consent = new GrowerConsentFormModel { GrowerConsentCommonId = id, ContactName = "TestConsent", Email = "*****@*****.**", }; await service.CreateGrowerConsent(consent); var insertedConsent = await consentData.GetConsent(id); Assert.AreEqual(consent.ContactName, insertedConsent.ContactName); Assert.AreEqual(consent.Email, insertedConsent.Email); }
public async Task CreateConsentCropAcres() { consentData = new CdipData(); service = new GrowerConsentService(consentData, confirmationTokenService); var consent = new GrowerConsentFormModel { GrowerConsentCommonId = Guid.NewGuid().ToString(), ContactName = "TestConsent1", Email = "*****@*****.**", CropAcres = new List <CropAcresModel>() { new CropAcresModel { CropId = Guid.NewGuid().ToString(), CropName = "Rubbish", CropAcres = 100500 }, new CropAcresModel { CropId = Guid.NewGuid().ToString(), CropName = "Garbage", CropAcres = 1050 }, } }; await service.CreateGrowerConsent(consent); var insertedConsent = await consentData.GetConsent(consent.GrowerConsentCommonId); Assert.AreEqual(consent.ContactName, insertedConsent.ContactName); foreach (var crop in consent.CropAcres) { var insertedCrop = await consentData.GetCropAcres(crop.CropId); Assert.AreEqual(insertedCrop.CropName, crop.CropName); Assert.AreEqual(insertedCrop.CropAcres, crop.CropAcres); } }