public ActionResult <BugNote> Put(string id, [FromBody] BugNote bugNoteData) { try { bugNoteData.Id = id; var myBugNote = _bns.EditBugNote(bugNoteData); return(Ok(myBugNote)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <BugNote> Post([FromBody] BugNote bugNoteData) { try { return(Ok(_bns.AddBugNote(bugNoteData))); } catch (Exception e) { return(BadRequest(e.Message)); } }
// NOTE All tests pass on front end now but I lose the check for if a bug is open. public BugNote EditBugNote(BugNote bugNoteData) { // var bug = GetBugById(bugNoteData.BugId); var bugNote = GetBugNoteById(bugNoteData.Id); // if (bug.ClosedDate != null) { throw new Exception("Quit wasting time... This bug is already resolved!"); } bugNote.Timestamp = DateTime.Now; bugNote.Body = bugNoteData.Body; return(bugNote); }
public BugNote EditBugNote(BugNote bugNoteData) //TODO need to add logic to check for open bug { var bugNote = _repo.BugNotes.Find(b => b.Id == bugNoteData.Id); if (bugNoteData == null) { throw new Exception("Note cannot be edited"); } bugNoteData.Body = bugNoteData.Body; return(bugNoteData); }
public ActionResult <BugNote> Post([FromBody] BugNote myBugNote) { try { BugNote bugnote = _bns.AddNote(myBugNote); return(Ok(myBugNote)); } catch (Exception e) { return(BadRequest(e.Message)); //code snippet } }
public ActionResult Post([FromBody] BugNote noteData) { try { BugNote newNote = _bn.AddNote(noteData); return(Ok(newNote)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <BugNote> Get(string id) { try { BugNote note = _bn.GetBugNotebyId(id); return(Ok(note)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public BugNote EditNote(BugNote noteData) { var bugNote = GetBugNotebyId(noteData.Id); if (bugNote.ClosedTicket == true) { throw new Exception("You can't edit notes to resolved tickets"); } bugNote.Body = noteData.Body; bugNote.Timestamp = DateTime.Now; return(bugNote); }
public ActionResult Put(string id, [FromBody] BugNote noteData) { try { noteData.Id = id; var note = _bn.EditNote(noteData); return(Ok(note)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public BugNote EditBugNote(BugNote bugNoteData) { var myBugNote = GetBugNoteByID(bugNoteData.Id); var tempBug = GetBugByID(myBugNote.BugId); if (tempBug.ClosedDate != null) { throw new Exception("You can not add to a clossed bug"); } myBugNote.Body = bugNoteData.Body; myBugNote.Timestamp = DateTime.Now; return(myBugNote); }
public BugNote AddBugNote(BugNote bugNoteData) { var bug = GetBugById(bugNoteData.BugId); if (bug.ClosedDate != null) { throw new Exception("Quit wasting time... This bug is already resolved!"); } bugNoteData.Id = Guid.NewGuid().ToString(); bugNoteData.Timestamp = DateTime.Now; _repo.BugNotes.Add(bugNoteData); return(bugNoteData); }
public BugNote AddBugNote(BugNote bugNoteData) { var bug = _repo.Bugs.Find(b => b.Id == bugNoteData.BugId); if (bug.ClosedDate != null) { throw new Exception("This bug is already closed."); } bugNoteData.Id = Guid.NewGuid().ToString(); bugNoteData.Timestamp = DateTime.Now; bug.LastModified = DateTime.Now; _repo.BugNotes.Add(bugNoteData); return(bugNoteData); }
public BugNote AddNote(BugNote noteData) { Bug bug = _repo.Bugs.Find(b => b.Id == noteData.BugId); if (bug == null) { throw new Exception("Can't find that ticket"); } if (bug.ClosedTicket) { throw new Exception("You can't add notes to resolved tickets"); } noteData.Timestamp = DateTime.Now; noteData.Id = Guid.NewGuid().ToString(); _repo.BugNotes.Add(noteData); return(noteData); }
public BugNote AddNote(BugNote newBugNote) { var alreadyNote = _repo.BugNotes.Find(bn => bn.Body == newBugNote.Body); if (alreadyNote != null) { throw new Exception("Note already exists for this bug"); } var tempBug = GetBugByID(newBugNote.BugId); if (tempBug.ClosedDate != null) { throw new Exception("You can not add to a clossed bug"); } newBugNote.Id = Guid.NewGuid().ToString(); newBugNote.Timestamp = DateTime.Now; _repo.BugNotes.Add(newBugNote); return(newBugNote); }