Example #1
0
        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));
                }
            }
        }
Example #2
0
 private Board GetBoardFromDatabase()
 {
     using (var session = RavenDatabase.GetSession())
     {
         var repo = new BoardRepository(session);
         return(repo.Get());
     }
 }
Example #3
0
        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));
        }
Example #4
0
        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));
                }
            }
        }