public void Change(VendorChangeCommand command) { Add(command); Id = command.Id ?? string.Empty; UpdatedDateUtc = command.UpdatedDateUtc; UpdatedUid = command.UpdatedUid ?? string.Empty; }
public async Task <ICommandResult> Handle(VendorChangeCommand mesage) { try { Vendor vendor = new Vendor(mesage.Version); RVendor vendorFromDb = await _vendorService.GetFromDb(mesage.Id); string code = string.Empty; if (string.IsNullOrEmpty(vendorFromDb.Code)) { long systemIdentity = await _commonService.GetNextId(typeof(Vendor)); code = Common.Common.GenerateCodeFromId(systemIdentity, 3); } vendor.Change(mesage); await _vendorService.ChangeToDb(vendor, code); ICommandResult result = new CommandResult() { Message = "", ObjectId = vendor.Id, Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (Exception e) { e.Data["Param"] = mesage; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }
public async Task <CommandResult> SendCommand(VendorChangeCommand command) { CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command); return(commandResult); }