コード例 #1
0
        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);
            }
        }