public bool CreateMood(MoodCreate model) { var entity = new Mood() { MoodName = model.MoodName, }; using (var ctx = new ApplicationDbContext()) { ctx.Moods.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(MoodCreate mood) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateMoodService(); if (!service.CreateMood(mood)) { return(InternalServerError()); } return(Ok()); }