public void Change(CategoryChangeCommand command) { Id = command.Id; LanguageId = command.LanguageId; Code = command.Code; CreatedDateUtc = Extensions.GetCurrentDateUtc(); CreatedUid = command.CreatedUid; UpdatedDateUtc = Extensions.GetCurrentDateUtc(); UpdatedUid = command.CreatedUid ?? string.Empty; ParentId = command.ParentId; Name = command.Name; Description = command.Description; DisplayOrder = command.DisplayOrder; Version = command.Version; Status = command.Status; AddOrChangeEvent(); }
public async Task <ICommandResult> Handle(CategoryChangeCommand mesage) { try { Category category = new Category(); RCategory categoryFromDb = await _categoryService.Get(mesage.LanguageId, mesage.Id); //string code = string.Empty; //if (string.IsNullOrEmpty(categoryFromDb.Code)) //{ // long systemIdentity = await _commonService.GetNextId(typeof(Customer)); // code = Common.Common.GenerateCodeFromId(systemIdentity, 3); //} category.Change(mesage); await _categoryService.ChangeToDb(category); //await _categoryRepository.Change(category); ICommandResult result = new CommandResult() { Message = "", ObjectId = category.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(CategoryChangeCommand command) { CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command); return(commandResult); }