public static void InsertCollection(Collection c) { naturenet_dataclassDataContext db = new naturenet_dataclassDataContext(); db.Collections.InsertOnSubmit(c); Action a = new Action(); a.date = DateTime.Now; a.type_id = 1; a.object_type = c.GetType().ToString(); a.user_id = c.user_id; try { db.SubmitChanges(); a.object_id = c.id; db.Actions.InsertOnSubmit(a); db.SubmitChanges(); } catch (Exception e) { log.WriteErrorLog(e); } }
partial void DeleteCollection(Collection instance);
partial void UpdateCollection(Collection instance);
partial void InsertCollection(Collection instance);
private void detach_Collections(Collection entity) { this.SendPropertyChanging(); entity.Activity = null; }
private void attach_Collections(Collection entity) { this.SendPropertyChanging(); entity.User = this; }
public static int get_or_create_collection(naturenet_dataclassDataContext db, string user_name, string avatar, int activity_id, DateTime dt) { int user_id =0; var ru = from u in db.Users where u.name == user_name select u; if (ru.Count() == 0) { return 0; } else { user_id = ru.First<User>().id; } var r = from c in db.Collections where ((c.user_id == user_id) && c.activity_id == activity_id) orderby c.date descending select c; if (r.Count() != 0) { foreach (Collection col in r) { if (configurations.GetDate_Formatted(col.date) == configurations.GetDate_Formatted(dt)) return col.id; } } // create new collection Collection cl = new Collection(); cl.activity_id = activity_id; cl.date = dt; cl.name = configurations.GetDate_Formatted(dt); cl.user_id = user_id; database_manager.InsertCollection(cl); return cl.id; }
public static int get_or_create_collection(int user_id, int activity_id, DateTime dt) { naturenet_dataclassDataContext db = new naturenet_dataclassDataContext(); var r = from c in db.Collections where ((c.user_id == user_id) && c.activity_id == activity_id) orderby c.date descending select c; if (r.Count() != 0) { foreach (Collection col in r) { if (configurations.GetDate_Formatted(col.date) == configurations.GetDate_Formatted(dt)) return col.id; } } // create new collection Collection cl = new Collection(); cl.activity_id = activity_id; cl.date = dt; cl.name = configurations.GetDate_Formatted(dt); cl.user_id = user_id; database_manager.InsertCollection(cl); return cl.id; }