Ejemplo n.º 1
0
        public async Task <ICommandResult> Handle(ProductAttributeCommand mesage)
        {
            try
            {
                var item = new ProductAttribute();
                item.Init(mesage);

                if (!string.IsNullOrEmpty(mesage.Id))
                {
                    await _productAttributeService.UpdateToDb(item);

                    await _eventSender.Notify(item.Events);
                }
                else
                {
                    await _productAttributeService.AddToDb(item);

                    await _eventSender.Notify(item.Events);
                }

                var result = new CommandResult
                {
                    Message  = "",
                    ObjectId = item.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);
            }
        }