// POST /api/blames public void Post(BlameViewModel blame) { using (BlameRepository repo = new BlameRepository(User.Identity.GetUserId())) { repo.Add(new Blame { ShameID = blame.ShameID, UserID = blame.UserID }); } }
// GET /api/blames/{id} public BlameViewModel Get(long id) { using (BlameRepository repo = new BlameRepository(User.Identity.GetUserId())) { Blame blame = repo.Get().SingleOrDefault(b => b.ID == id); if (blame == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(new BlameViewModel { ID = blame.ID, CreatedAt = blame.CreatedAt, CreatedBy = blame.CreatedBy, ShameID = blame.ShameID, UserID = blame.UserID }); } }