public bool CreateEmotion(EmotionCreate model) { var entity = new Emotion() { OwnerId = _userId, EmotionType = model.EmotionType }; using (var ctx = new ApplicationDbContext()) { ctx.Emotions.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(EmotionCreate emotion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateEmotionService(); if (!service.CreateEmotion(emotion)) { return(InternalServerError()); } return(Ok()); }