public async Task <IShopCustomerSubsetReportDto> GetShopCustomerSubsetReport(Guid shopId) { var appSetting = _applicationSettingRepository.AsQuery().FirstOrDefault(); var shop = await _repository.FindAsync(shopId); if (shop == null) { throw new DomainException("فروشگاه یافت نشد"); } var countShopCustomerSubsetNotSettlement = shop.CustomerSubsets.Count(p => !p.IsSettlement && !p.HavePaidFactor); var countShopCustomerSubsetHaveFactorPaidSumAmount = shop.CustomerSubsets.Count(p => !p.IsSettlement && p.HavePaidFactor); var result = new ShopCustomerSubsetReportDto { Count = shop.CustomerSubsets.Count, PaidFactorCount = shop.CustomerSubsets.Count(p => p.HavePaidFactor), SettlementCount = shop.CustomerSubsets.Count(p => p.IsSettlement), NotSettlementCount = shop.CustomerSubsets.Count(p => !p.IsSettlement), ShopCustomerSubsetHaveFactorPaidSumAmount = countShopCustomerSubsetHaveFactorPaidSumAmount * appSetting.ShopCustomerSubsetHaveFactorPaidAmount, ShopCustomerSubsetSumAmount = countShopCustomerSubsetNotSettlement * appSetting.ShopCustomerSubsetAmount }; return(result); }
public async Task <IList <ICustomerAddressDto> > GetCustomerAddressesById(Guid id) { var customer = await _repository.FindAsync(id); if (customer == null) { throw new DomainException("مشتری یافت نشد"); } return(customer.CustomerAddresses.ToList().Select(item => item.ToDto()).ToList()); }
public async Task <IPromoterDto> GetAsync(Guid id) { var promoter = await _repository.FindAsync(id); if (promoter == null) { throw new DomainException("شخص یافت نشد"); } return(promoter.ToDto()); }
public virtual async Task <Result <TGetModel> > GetAsync(params object[] keyValues) { var entity = await Repository.FindAsync(keyValues); if (entity == null) { return(Result <TGetModel> .NotFound()); } else { return(Result <TGetModel> .Success(Mapper.Map <TGetModel>(entity))); } }
/// <summary> /// Returns instance of type <typeparamref name="TDomainModel"/> associated with the <paramref name="key"/> in the <paramref name="repository"/>. /// If no such instance exists, throws <see cref="AggregateRootNotFoundException"/>. /// </summary> /// <typeparam name="TDomainModel">The type of the model to return.</typeparam> /// <param name="repository">The repository.</param> /// <param name="key">The key to model associated with.</param> /// <returns>The instance of model associated with the <paramref name="key"/>.</returns> /// <exception cref="AggregateRootNotFoundException">When no such model is associated with the <paramref name="key"/>.</exception> public static async Task <TDomainModel> GetAsync <TDomainModel>(this IReadOnlyRepository <TDomainModel, IKey> repository, IKey key) where TDomainModel : AggregateRoot { Ensure.NotNull(repository, "repository"); TDomainModel model = await repository.FindAsync(key); if (model == null) { throw new AggregateRootNotFoundException(key); } return(model); }
public async Task <IDeleteContext> HandleAsync(IKey key) { TKey modelKey = key as TKey; Ensure.NotNull(modelKey, "key"); TModel model = await repository.FindAsync(modelKey); if (model == null) { return(new MissingHandlerContext(key)); } return(await HandleModelAsync(model)); }
public async Task <IEnumerable <IProductDiscountDto> > GetProductPercentDiscountById(Guid percentDiscountId) { var discount = await _percentRepository.FindAsync(percentDiscountId); var result = discount.ProductDiscounts.Select(p => new ProductDiscountDto { UserInfo = new UserInfoDto { UserId = p.UserInfo.UserId, FirstName = p.UserInfo.FirstName, LastName = p.UserInfo.LastName }, CreationTime = p.CreationTime, Product = p.Product.ToProductWithDiscountDto() }); return(result); }
protected override async Task <AccountModel> HandleCore(GetAccountQuery request) { var account = await repo.FindAsync(new GetById(new AccountId(request.Id))); if (account == null) { throw new BadRequestException("Account was not found"); } return(new AccountModel() { AccountId = account.Id, Balance = account.Balance.Amount, Currency = account.Balance.Currency.ToString(), LastName = account.Holder.LastName, FirstName = account.Holder.FirstName }); }
public Task <TAggregateRoot> FindAsync(TKey ID, CancellationToken cancellationToken = default) => _inner.FindAsync(ID, cancellationToken);
public virtual Task <IEnumerable <TEntity> > FindAsync(Expression <Func <TEntity, bool> > predicate, CancellationToken cancellationToken = default(CancellationToken)) { return(_readOnlyRepository.FindAsync(predicate, cancellationToken)); }
/// <inheritdoc/> public Task <Equipment> GetOrDefaultAsync(int id, CancellationToken cancellation) { return(_equipmentRepository.FindAsync(id, cancellation)); }
public async Task <IMarketerFullInfoDto> Get(long id) { var marketer = await _repository.FindAsync(id); return(marketer.ToFullInfoDto()); }