コード例 #1
0
ファイル: EmotionService.cs プロジェクト: dknauff/DreamAPI
        public bool UpdateEmotion(EmotionEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Emotions
                    .Single(e => e.EmotionId == model.EmotionId && e.OwnerId == _userId);

                entity.EmotionType = model.EmotionType;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
ファイル: EmotionController.cs プロジェクト: dknauff/DreamAPI
        public IHttpActionResult Put(EmotionEdit emotion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateEmotionService();

            if (!service.UpdateEmotion(emotion))
            {
                return(InternalServerError());
            }

            return(Ok());
        }