public IHttpActionResult Post(NoteTwoCreate note) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateNoteTwoService(); if (!service.CreateNoteTwo(note)) { return(InternalServerError()); } return(Ok()); }
public bool CreateNoteTwo(NoteTwoCreate model) { var entity = new NoteTwo() { OwnerId = _userId, Title = model.Title, Content = model.Content, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Notes.Add(entity); return(ctx.SaveChanges() == 1); } }