private bool TryCreateNewPetDbRecord(NopePet requestData, out IResponse response) { var newPet = requestData.ToNewPetModel(); ErrorMessage errorMessage; if (!_petPersister.TryPersist(ref newPet, out errorMessage)) { response = new UserSessionPetResponse().SetErrorResponse(errorMessage); return(false); } return(TryCreateNewPetMetricsDbRecord(ref newPet, out response)); }
private bool TryPersistRecord(ISiteData requestData, out IResponse response) { if (requestData is NewUser) { var data = ((NewUser)requestData).ToUserModel(); ErrorMessage errorMessage; if (_userPersister.TryPersist(ref data, out errorMessage)) { response = new RegistrationResponse().SetSuccessResponse(data.ToRegistrationResponseData()); return(true); } response = new RegistrationResponse().SetErrorResponse(errorMessage); return(false); } response = null; return(false); }
private bool TryCreateNewPetMetricsDbRecord(ref Pet newPet, out IResponse response) { var nopePet = _userSessionBuilder.CreatePet(newPet, _user); var petName = newPet.Name; var petVitals = nopePet.First(pet => pet.PetName == petName).PetHealth; foreach (var petVital in petVitals) { var newPetVitals = petVital.ToPetMetricModel(); ErrorMessage errorMessage; if (!_petMetricPersister.TryPersist(ref newPetVitals, out errorMessage)) { response = new UserSessionPetResponse().SetErrorResponse(errorMessage); return(false); } } response = new UserSessionPetResponse().SetSuccessResponse(nopePet); return(true); }