public IActionResult Post([FromBody] string entry) { try { if (string.IsNullOrEmpty(entry)) { var persistedEntry = new PersistedEntry() { Entry = entry, CreatedDate = DateTime.Now }; _repository.AddEntryToPersistedItems(persistedEntry); if (_repository.SaveAll()) { return(Created($"/api/history/{persistedEntry.Id}", persistedEntry)); } } else { return(BadRequest("Input string can not be null or empty")); } } catch (Exception ex) { } return(BadRequest("Failed to add new entry to persisted list")); }
public void AddEntryToPersistedItems(PersistedEntry entry) { _ctx.Add(entry); }