/// <summary> /// /// </summary> public void Edit() { var db = new MonitoringDB(); db.Users.Attach(this); db.Entry(this).State = EntityState.Modified; db.SaveChanges(); }
public static void ReCreareDB() { var db = new MonitoringDB(); if (db.Database.Exists()) { db.Database.Delete(); } db.Database.Create(); }
/// <summary> /// NotImplementedException /// </summary> /// <param name="id"></param> /// <returns></returns> public static bool Delete(int id) { throw new NotImplementedException(); var db = new MonitoringDB(); UsersGroup currentGroup = db.UserGroups.Where(x => x.UsersGroupId == id).First(); if (currentGroup == null) { return(false); } /* * var fullEntries = dbContext.tbl_EntryPoint * .Join( * dbContext.tbl_Entry, * entryPoint => entryPoint.EID, * entry => entry.EID, * (entryPoint, entry) => new { entryPoint, entry } * ) * * * //try * //{ * if (db.Users.Join(db.UserGroups, * entryPoint => entryPoint.Group, * entry => entry.UsersGroupId, * (entryPoint, entry) => new { entryPoint, entry })) * //.Count() > 0) * { * foreach (var item in db.Users.Where(x=>x.Group==currentGroup)) * { * db.Users.Remove(item); * } * db.SaveChanges(); * } * else * {*/ db.UserGroups.Remove(db.UserGroups.Where(x => x.UsersGroupId == id).First()); //} db.SaveChanges(); return(true); /* } * catch (Exception err) * { * Debug.WriteLine(err.Message); * return false; * }*/ }
/// <summary> /// NotImplementedException(); /// </summary> /// <param name="id"></param> /// <returns></returns> public static bool Delete(int id) { throw new NotImplementedException(); var db = new MonitoringDB(); //try //{ db.Users.Remove(db.Users.Where(x => x.UserId == id).First()); return(true); /*} * catch (Exception err) * { * Debug.WriteLine(err.Message); * return false; * }*/ }
public static List <User> GetUsers() { var db = new MonitoringDB(); return(db.Users.ToList()); }