Ejemplo n.º 1
0
        public async Task <ApiResult> AccountRegister(CreateAccountDto input)
        {
            using var tran = await unitofWork.BeginTransactionAsync();

            var account = new Account();

            account.CreateAccount(input.LoginName, input.NickName, input.Password, Common.GetMD5SaltCode);
            accountRepository.Add(account);
            if (await new UniqueAccountIdSpecification(accountRepository).IsSatisfiedBy(account))
            {
                await unitofWork.CommitAsync(tran);
            }
            return(ApiResult.Ok("用户注册成功"));
        }
Ejemplo n.º 2
0
        public async Task <ApiResult> RoleCreate(RoleCreateDto input)
        {
            using var tran = await unitofWork.BeginTransactionAsync();

            var role = new Role();

            role.SetRole(input.RoleName, input.SuperAdmin, input.Permissions);
            rolerepository.Add(role);
            if (await new PermissionValidityCheckSpecification(permissionRepository).IsSatisfiedBy(role))
            {
                await unitofWork.CommitAsync(tran);
            }
            return(ApiResult.Ok("角色创建成功"));
        }
        public async Task <ApiResult> Deliver(LogisticsDeliverDto input)
        {
            using var tran = await unitofWork.BeginTransactionAsync();

            var order = await orderRepository.GetAsync(input.OrderId);

            if (order == null)
            {
                throw new ApplicationServiceException("订单无效!");
            }
            var logistics   = new Logistics();
            var mallSetting = (await mallSettingQuery.GetMallSetting()).GetData <MallSettingOutInfo>();

            logistics.Deliver(input.OrderId, (LogisticsType)input.LogisticsType, input.LogisticsNo, mallSetting.DeliverName, mallSetting.DeliverAddress, HttpContextExt.Current.User.Id, order.ConsigneeInfo.Name, order.ConsigneeInfo.Address, input.DeliveTime);
            repository.Add(logistics);
            if (await new LogisticsDeliverCheckSpecification(repository).IsSatisfiedBy(logistics))
            {
                await unitofWork.CommitAsync(tran);

                await eventBus.SendEvent(EventTopicDictionary.Logistics.LogisticsDeliverSucc, new OperateLogisticsSuccessEvent(logistics, HttpContextExt.Current.User.LoginName));
            }
            return(ApiResult.Ok());
        }