Пример #1
0
 // 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
         });
     }
 }
Пример #2
0
        // 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
                });
            }
        }