public Current_Price GetPriceData(int productId) { var currentPrice = new Current_Price { currency_code = "USD", value = 14.92 }; return(currentPrice); }
public void UpdatePriceData(int id, Current_Price currentPrice) { try { var serializedDataToWrite = JsonConvert.SerializeObject(currentPrice); var manager = new RedisManagerPool(Environment.GetEnvironmentVariable("redis_ip") + ":" + Environment.GetEnvironmentVariable("redis_port")); using (var client = manager.GetClient()) { client.Set(id.ToString(), serializedDataToWrite); } }catch (Exception ex) { throw ex; } }
public Product GetProductById(int productId) { var product2Return = new Product { name = "TestProd", id = productId }; var current_Price = new Current_Price { value = 7, currency_code = "USD" }; return(product2Return); }
public static void Main(string[] args) { // this code should be taken out for production // but since this is a coding challenge, this seemed // to be the easiest way to get the data in the DB var dataForDB = new Current_Price { currency_code = "USD", value = 18.12 }; var writeThis = JsonConvert.SerializeObject(dataForDB); var manager = new RedisManagerPool(Environment.GetEnvironmentVariable("redis_ip") + ":" + Environment.GetEnvironmentVariable("redis_port")); using (var client = manager.GetClient()) { client.Set("13860428", writeThis); } BuildWebHost(args).Run(); }
public void testGetProductRedisDB() { var testProductId = 13860428; var dataForDB = new Current_Price(); dataForDB.currency_code = "USD"; dataForDB.value = 18.12; var writeThis = JsonConvert.SerializeObject(dataForDB); var manager = new RedisManagerPool("localhost:6379"); using (var client = manager.GetClient()) { client.Set(testProductId.ToString(), writeThis); } var redisRepo = new RedisDB(); var actualResults = redisRepo.GetPriceData(testProductId); Assert.AreEqual(actualResults, dataForDB); }
public Current_Price GetPriceData(int productId) { var currentPrice = new Current_Price(); try { var manager = new RedisManagerPool(Environment.GetEnvironmentVariable("redis_ip") + ":" + Environment.GetEnvironmentVariable("redis_port")); using (var client = manager.GetClient()) { var returnedData = client.Get <string>(productId.ToString()); currentPrice = JsonConvert.DeserializeObject <Current_Price>(returnedData); } } catch { currentPrice = new Current_Price { value = -1 }; } return(currentPrice); }
public void UpdatePriceData(int id, Current_Price current_price) { return; }
public void UpdatePriceData(int id, Current_Price current_price) { throw new NotImplementedException(); }