public object Set(string arg) { DataItem item = DataItem.Make(arg); if (item == null) { return("ERR: " + arg); } string id = item.ID; DataItem old = _context.DataItems.FirstOrDefault(t => t.ID == id); if (old == null) { _context.DataItems.Add(item); _context.SaveChanges(); return(new ObjectResult(item.SetResult("ADDED"))); } else { item.CopyTo(old); _context.SaveChanges(); return(new ObjectResult(old.SetResult("UPDATED"))); } }