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); } }
public IHttpActionResult Put(EmotionEdit emotion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateEmotionService(); if (!service.UpdateEmotion(emotion)) { return(InternalServerError()); } return(Ok()); }