/// <summary> /// 执行命令 /// </summary> /// <param name="cmd"></param> public void Execute(CM_AccountCommand cmd) { if (cmd.MCM_Account.DataEntityAction == DataEntityActions.Add) { service.Add(cmd.MCM_Account); } else if (cmd.MCM_Account.DataEntityAction == DataEntityActions.Update) { if (cmd.MCM_Account.ID != 0) { throw new ArgumentException("ID不存在!"); } service.Update(cmd.MCM_Account); } else if (cmd.MCM_Account.DataEntityAction == DataEntityActions.Delete) { if (cmd.MCM_Account.ID != 0) { throw new ArgumentException("ID不存在!!"); } service.Delete(cmd.MCM_Account); } service.Context.Commit(); if (service.SimpleResult != null) { cmd.SimpleResult = new SimpleResult(service.SimpleResult.Result, service.SimpleResult.Message); } }
/// <summary> /// 执行命令 /// </summary> /// <param name="cmd"></param> public void Execute(AddAccountCommand cmd) { if (string.IsNullOrEmpty(cmd.MCM_Account.DefineAccountCode)) { throw new ArgumentException("编号是必须的!"); } service.Add(cmd.MCM_Account); service.Context.Commit(); if (service.SimpleResult != null) { cmd.SimpleResult = new SimpleResult(service.SimpleResult.Result, service.SimpleResult.Message); } }