Ejemplo n.º 1
0
 public void Change(MenuChangeCommand command)
 {
     Id             = command.Id;
     LanguageId     = command.LanguageId;
     Code           = string.Empty;
     UpdatedDateUtc = Extensions.GetCurrentDateUtc();
     UpdatedUid     = string.Empty;
     ParentId       = command.ParentId;
     Name           = command.Name;
     Type           = (EnumDefine.MenuTypeEnum)command.Type;
     Url            = command.Url;
     Condition      = command.Condition;
     Position       = (EnumDefine.MenuPositionEnum)command.Position;
     StoreId        = command.StoreId;
     Status         = command.Status;
     Priority       = command.Priority;
     AddOrChangeEvent();
 }
        public async Task <ICommandResult> Handle(MenuChangeCommand message)
        {
            try
            {
                ICommandResult result;
                RMenu          rMenu = await _menuService.Get(message.Id);

                if (rMenu == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Menu not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Template_NotFound
                    };
                    return(result);
                }
                Menu menu = new Menu(rMenu);
                menu.Change(message);
                await _menuRepository.Change(menu);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = menu.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = message;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
Ejemplo n.º 3
0
        public async Task <CommandResult> SendCommand(MenuChangeCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }