anchor.diff:  
   new_event_id(S) ->
       Id = S#state.event_id+1,
  -    case get_event_by_id(S, Id) of
  +    case get_event_by_id(Id, S) of
           false ->
               {S#state{event_id=Id}, Id};
           _ ->
  
positive.code:                             {reason, "unknown event id"}]}
      end,
      {Res, S};
  %% http://idrott/idrott/create_event?sid=1234567890&name=foo&date=2014-10-01&pm=foo&timeschedule=foo&location=vallen&funcinfo=foo&funccount=10&funccall=open
  do_cmd("create_event", L0, Json, S) ->
      Sid = get_val("sid", L0, ""),
      case get_user_by_id(Sid, S) of
          U=#user{} when U#user.role == admin ->
              L = case Json of
                       {struct, Ops} ->  L0 ++ Ops;
                       _ -> L0
                   end,
              %% login successful
              {S2, Id} = new_event_id(S),
              Event = apply_event_ops(#event{id=Id}, L),
              NewS = S2#state{events=[Event|S2#state.events]},
              Res = {struct, [{status, "ok"},
                              {event, event2object(Event)}]};
  
negative.code:     apply_event_ops(E, Ops).
  
  apply_event_json(E, {struct, Ops}) ->
      apply_event_ops(E, Ops).
  
  %%
  
  