public static double ShippingPrice(string shopCode = "culture") { double result = 0; try { OhayooDB db = new OhayooDB(); result = db.proShippingJapan(RakutenInfo(shopCode)).FirstOrDefault().price.Value; } catch (Exception ex) { Console.WriteLine(ex.Message); } return(result); }
public HttpResponseMessage Get() { double rate = 0; OhayooDB db = new OhayooDB(); try { rate = ExchangeRateVietComBankUtils.VietComBank(url); //update exchage rate if (db.ExchageRates.Count() > 0) { if (db.ExchageRates.OrderByDescending(n => n.id).FirstOrDefault().exRate != rate) { ExchageRate model = new ExchageRate() { createDate = DateTime.Now, exRate = rate }; db.ExchageRates.Add(model); db.SaveChangesAsync(); } } else { ExchageRate model = new ExchageRate() { createDate = DateTime.Now, exRate = rate }; db.ExchageRates.Add(model); db.SaveChangesAsync(); } if (db.ExchageRateCharts.Count() == 0) { rate = rate * 1.02; } else { rate = rate * db.ExchageRateCharts.OrderByDescending(n => n.id).FirstOrDefault().exRate.Value; } } catch { if (db.ExchageRates.Count() > 0) { rate = db.ExchageRates.OrderByDescending(n => n.id).FirstOrDefault().exRate.Value; } } return(Request.CreateResponse(HttpStatusCode.OK, rate)); }
public HttpResponseMessage Post() { List <CategoryResponse> list = new List <CategoryResponse>(); try { OhayooDB db = new OhayooDB(); list.AddRange(db.Categories.Select(n => new CategoryResponse() { description = n.description, id = n.id, is_leaf = n.is_leaf.Value, level = n.levelCate.Value, name = n.name, parent_id = n.parent_id.Value, status = n.status.Value })); } catch { } return(Request.CreateResponse(HttpStatusCode.OK, list)); }
public static double ExchangeRate() { double rate = 219.22; OhayooDB db = new OhayooDB(); try { if (db.ExchageRates.Count() > 0) { rate = db.ExchageRates.OrderByDescending(n => n.id).FirstOrDefault().exRate.Value; } if (db.ExchageRateCharts.Count() == 0) { rate = rate * 1.02; } else { rate = rate * db.ExchageRateCharts.OrderByDescending(n => n.id).FirstOrDefault().exRate.Value; } } catch { } return(rate); }