public HttpResponseMessage Put(string id, Sticky sticky) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); var existingSticky = board.Stickies.Where(s => s.Id == id).FirstOrDefault(); if (existingSticky == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Sticky with that id not found.")); } else { existingSticky.Content = sticky.Content; existingSticky.X = sticky.X; existingSticky.Y = sticky.Y; existingSticky.Height = sticky.Height; existingSticky.Width = sticky.Width; boardRepo.Save(board); return(Request.CreateResponse(HttpStatusCode.OK)); } } }
private Board GetBoardFromDatabase() { using (var session = RavenDatabase.GetSession()) { var repo = new BoardRepository(session); return(repo.Get()); } }
public HttpResponseMessage Post(Sticky sticky) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); board.AddSticky(sticky); boardRepo.Save(board); } return(Request.CreateResponse <string>(HttpStatusCode.OK, sticky.Id)); }
public HttpResponseMessage Get(string id) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); var sticky = board.Stickies.Where(s => s.Id == id).FirstOrDefault(); if (sticky == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Sticky with that id not found.")); } else { return(Request.CreateResponse <Sticky>(HttpStatusCode.OK, sticky)); } } }