public bool CreateEmotionDream(EmotionDreamCreate model) { var entity = new EmotionDream() { OwnerId = _userId, EmotionId = model.EmotionId, DreamId = model.DreamId }; using (var ctx = new ApplicationDbContext()) { ctx.EmotionDreams.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(EmotionDreamCreate dream) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateEmotionDreamService(); if (!service.CreateEmotionDream(dream)) { return(InternalServerError()); } return(Ok()); }