public bool UpdateBug(string bug, int key) { var bugS = JsonConvert.DeserializeObject <BugMDB>(bug); //ObjectId id; //ObjectId.TryParse(bug.Id, out id); try { var bugs = database.GetCollection <BugMDB>("bugs"); var query = Query <BugMDB> .EQ(e => e.Id, bugS.Id); BugMDB b = bugs.FindOne(query); b.Problem = (b.Problem != bugS.Problem) ? bugS.Problem : b.Problem; if (b.Response != bugS.Response) { b.Response = bugS.Response; b.DateResolved = DateTime.Now; } bugs.Save(b); Clients.All.UpdateBug(b, key); return(true); } catch (Exception ex) { return(false); } }
public bool AddBug(BugMDB bug, int key) { try { var bugs = database.GetCollection<BugMDB>("bugs"); var b = new BugMDB { Problem = bug.Problem, Response = bug.Response, DateCreated = DateTime.Now }; bugs.Insert(b); Clients.Others.AddBug(b); Clients.Caller.AddMeBug(b, key); return true; } catch (Exception ex) { Clients.Caller.reportError("Unable to create bug."); return false; } }
public bool AddBug(BugMDB bug, int key) { try { var bugs = database.GetCollection <BugMDB>("bugs"); var b = new BugMDB { Problem = bug.Problem, Response = bug.Response, DateCreated = DateTime.Now }; bugs.Insert(b); Clients.Others.AddBug(b); Clients.Caller.AddMeBug(b, key); return(true); } catch (Exception ex) { Clients.Caller.reportError("Unable to create bug."); return(false); } }