public static Models.PlayOrder Get(int playOrderId) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = false }) { return ctx.PlayOrders.FirstOrDefault(x => x.PlayOrderId == playOrderId); } } catch { return null; } }
public static Models.AdHoc Get(string tag, string value) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = false }) { return ctx.AdHocs.FirstOrDefault(x => x.Tag == tag && x.Value == value); } } catch { return null; } }
public static List<Models.AdHoc> Get(string tag) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = false }) { return ctx.AdHocs.Where(x => x.Tag == tag).ToList(); } } catch { return null; } }
public static List<Models.PlayOrder> Get() { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = false }) { var orders = ctx.PlayOrders.Where(x => x.Name != "test" && x.Name != "Test").OrderBy(x => x.CreateDate).ToList(); return orders; } } catch { return null; } }
public static bool Save(Models.AdHoc adHoc) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = true }) { adHoc.CreateDate = System.DateTime.Now; ctx.AdHocs.InsertOnSubmit(adHoc); ctx.SubmitChanges(); return true; } } catch { return false; } }
public static int MarkAsPaid(int playOrderId) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = true }) { var playOrder = ctx.PlayOrders.FirstOrDefault(x => x.PlayOrderId == playOrderId); playOrder.Paid = true; playOrder.ModifyDate = System.DateTime.Now; ctx.SubmitChanges(); return playOrderId; } } catch { return -1; } }
public static bool Delete(string secret, int playOrderId) { if (secret.ToLower() != "oblivion") { return false; } try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = true }) { var playOrder = ctx.PlayOrders.FirstOrDefault(x => x.PlayOrderId == playOrderId); ctx.PlayOrders.DeleteOnSubmit(playOrder); ctx.SubmitChanges(); return true; } } catch { return false; } }
public static bool Save(string msg) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = true }) { var log = new Models.Log { CreateDate = System.DateTime.Now, LogType = "Error", Message = msg }; ctx.Logs.InsertOnSubmit(log); ctx.SubmitChanges(); return true; } } catch { return false; } }
public static int Save(Models.PlayOrder playOrder) { try { using (var ctx = new PlayDataContext { ObjectTrackingEnabled = true }) { playOrder.CreateDate = System.DateTime.Now; playOrder.Paid = false; ctx.PlayOrders.InsertOnSubmit(playOrder); ctx.SubmitChanges(); return playOrder.PlayOrderId; } } catch { return -1; } }