コード例 #1
0
ファイル: Program.cs プロジェクト: wallaceiam/CQRS.Light
        private static async Task NamePerson(IRepository<PersonDTO> personReadModel)
        {
            Console.Write("Enter person's Name: ");
            var name = Console.ReadLine();

            var id = Guid.NewGuid();
            var person = new Person(AggregateBus.Instance, id);
            person.NameMe(name);

            var personDTO = await personReadModel.GetByIdAsync(id);
            Console.WriteLine("Person ID: " + personDTO.Id);
            Console.WriteLine("Person Name: " + personDTO.Name);
            Console.WriteLine("Person Was Renamed: " + personDTO.WasRenamed);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wallaceiam/CQRS.Light
        private static async Task NameAndRenamePerson(IRepository<PersonDTO> personReadModel)
        {
            Console.Write("Enter person's Name: ");
            var name = Console.ReadLine();

            var id = Guid.NewGuid();
            var person = new Person(AggregateBus.Instance, id);
            person.NameMe(name);

            Console.Write("Enter person's Name: ");
            var renamedName = Console.ReadLine();
            person = await CQRS.Light.Core.EventStore.Instance.GetByIdAsync<Person>(id); 
            //can also do this: 
            // person = MongoEventStore.Instance.GetById(id) as Person;
            person.NameMe(renamedName);

            var personDTO = await personReadModel.GetByIdAsync(id);
            Console.WriteLine("Person ID: " + personDTO.Id);
            Console.WriteLine("Person Name: " + personDTO.Name);
            Console.WriteLine("Person Was Renamed: " + personDTO.WasRenamed);
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: brckrdgg/ZirveChallenge
 public async Task <TEntity> GetByIdAsync(int Id)
 {
     return(await _repository.GetByIdAsync(Id));
 }
コード例 #4
0
ファイル: OrderService.cs プロジェクト: smfichadiya/grandnode
 /// <summary>
 /// Gets a recurring payment
 /// </summary>
 /// <param name="recurringPaymentId">The recurring payment identifier</param>
 /// <returns>Recurring payment</returns>
 public virtual Task <RecurringPayment> GetRecurringPaymentById(string recurringPaymentId)
 {
     return(_recurringPaymentRepository.GetByIdAsync(recurringPaymentId));
 }
コード例 #5
0
 /// <summary>
 /// Gets a manufacturer
 /// </summary>
 /// <param name="manufacturerId">Manufacturer identifier</param>
 /// <returns>
 /// A task that represents the asynchronous operation
 /// The task result contains the manufacturer
 /// </returns>
 public virtual async Task <Manufacturer> GetManufacturerByIdAsync(int manufacturerId)
 {
     return(await _manufacturerRepository.GetByIdAsync(manufacturerId, cache => default));
 }
コード例 #6
0
 /// <summary>
 /// Gets a specification attribute option
 /// </summary>
 /// <param name="specificationAttributeOptionId">The specification attribute option identifier</param>
 /// <returns>
 /// A task that represents the asynchronous operation
 /// The task result contains the specification attribute option
 /// </returns>
 public virtual async Task <SpecificationAttributeOption> GetSpecificationAttributeOptionByIdAsync(int specificationAttributeOptionId)
 {
     return(await _specificationAttributeOptionRepository.GetByIdAsync(specificationAttributeOptionId, cache => default));
 }
コード例 #7
0
ファイル: DebtService.cs プロジェクト: Bugord/Collector
        public async Task DebtPayAsync(DebtPayDTO model)
        {
            var idClaim = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (!long.TryParse(idClaim, out var ownerId))
            {
                throw new UnauthorizedAccessException();
            }

            var debtToPay =
                await(await _debtRepository.GetAllAsync(debt => debt.Id == model.DebtId))
                .Include(debt => debt.Owner)
                .Include(debt => debt.Currency)
                .Include(debt => debt.Friend)
                .ThenInclude(friend => friend.FriendUser)
                .FirstOrDefaultAsync();

            if (debtToPay == null)
            {
                throw new ArgumentException("Debt is not exist");
            }

            Currency payCurrency = null;
            decimal  valueToPay  = 0;
            Charge   charge      = null;

            if (debtToPay.IsMoney)
            {
                if (!debtToPay.Value.HasValue || !debtToPay.CurrentValue.HasValue)
                {
                    throw new NoNullAllowedException("Value and CurrentValue can't be null");
                }

                if (!model.CurrencyId.HasValue)
                {
                    throw new ArgumentNullException(nameof(model.CurrencyId));
                }

                if (!model.Value.HasValue)
                {
                    throw new ArgumentNullException(nameof(model.Value));
                }

                if (!model.IsNotification && string.IsNullOrWhiteSpace(model.Token))
                {
                    throw new ArgumentException("Token can't be empty");
                }


                payCurrency = await _currenciesRepository.GetByIdAsync(model.CurrencyId.Value);

                if (payCurrency == null)
                {
                    throw new SqlNullValueException("Currency with such id not found");
                }

                valueToPay = await _exchangeRateService.Convert(model.Value.Value, payCurrency, debtToPay.Currency);

                if (debtToPay.CurrentValue + debtToPay.PendingValue + valueToPay > debtToPay.Value)
                {
                    throw new ArgumentException("You can't pay more, than debt ");
                }

                debtToPay.PendingValue += valueToPay;

                if (!model.IsNotification)
                {
                    charge = await _stripeChargeService.Charge(new ChargeDTO
                    {
                        Value    = (long)(valueToPay * 100),
                        Currency = debtToPay.Currency.CurrencySymbol,
                        Token    = model.Token
                    });
                }
            }
            else
            {
                if (!model.IsNotification)
                {
                    throw new ArgumentException("You can pay thing debts only by notification");
                }
            }

            var userToPay = debtToPay.IsOwnerDebter ? debtToPay.Friend.FriendUser : debtToPay.Owner;
            var userPayer = debtToPay.IsOwnerDebter ? debtToPay.Owner : debtToPay.Friend.FriendUser;


            var newPayment = new Payment
            {
                CreatedBy       = ownerId,
                Payer           = userPayer,
                UserToPay       = userToPay,
                Debt            = debtToPay,
                Value           = valueToPay,
                Currency        = payCurrency,
                Message         = model.Message,
                PaymentType     = model.IsNotification ? PaymentType.Notification : PaymentType.Stripe,
                Status          = Status.Pending,
                TransactionId   = charge?.BalanceTransactionId,
                TransactionDate = charge?.Created
            };

            await _paymentRepository.InsertAsync(newPayment);

            await _debtRepository.UpdateAsync(debtToPay);

            if (newPayment.PaymentType == PaymentType.Notification && debtToPay.Synchronize &&
                (debtToPay.IsOwnerDebter && debtToPay.Owner.Id == ownerId ||
                 !debtToPay.IsOwnerDebter && debtToPay.Friend.FriendUser.Id == ownerId))
            {
                await _hubContext.Clients.User(userToPay.Id.ToString())
                .SendAsync("UpdatePayNotifications");
            }


            await _hubContext.Clients.User(ownerId.ToString())
            .SendAsync("UpdateDebtById", debtToPay.Id);
        }
コード例 #8
0
        /// <summary>
        /// Получает этап бизнес процесса документа по его идентификатору.
        /// </summary>
        /// <param name="routeStageId">Идентификатор этапа бизнес процесса.</param>
        /// <returns>Этап бизнес процесса.</returns>
        private async Task <DicRouteStage> GetRouteStageById(int routeStageId)
        {
            IRepository <DicRouteStage> dicRouteStageRepository = Uow.GetRepository <DicRouteStage>();

            return(await dicRouteStageRepository.GetByIdAsync(routeStageId));
        }
コード例 #9
0
        /// <summary>
        /// 异步加载表单文档类型
        /// </summary>
        /// <param name="id">要加载的文档类型主键</param>
        public async Task <OperationResponse <DocumentTypeOutputDto> > LoadFormAsync(Guid id)
        {
            var dto = (await _documentTypeRepository.GetByIdAsync(id)).MapTo <DocumentTypeOutputDto>();

            return(new OperationResponse <DocumentTypeOutputDto>("加载成功", dto, OperationResponseType.Success));
        }
コード例 #10
0
 /// <summary>
 /// Gets a form by identifier
 /// </summary>
 /// <param name="formId">Form identifier</param>
 /// <returns>Banner</returns>
 public virtual Task <InteractiveForm> GetFormById(string formId)
 {
     return(_formRepository.GetByIdAsync(formId));
 }
コード例 #11
0
 public virtual async Task <TEntity> FindByIdAsync(CancellationToken cancellationToken, object id)
 {
     return(await _repository.GetByIdAsync(cancellationToken, id));
 }
コード例 #12
0
        /// <summary>
        /// Gets a product attribute
        /// </summary>
        /// <param name="productAttributeId">Product attribute identifier</param>
        /// <returns>Product attribute </returns>
        public virtual Task <ProductAttribute> GetProductAttributeById(string productAttributeId)
        {
            string key = string.Format(CacheKey.PRODUCTATTRIBUTES_BY_ID_KEY, productAttributeId);

            return(_cacheManager.GetAsync(key, () => _productAttributeRepository.GetByIdAsync(productAttributeId)));
        }
コード例 #13
0
 public async Task <TrangThaiDuAn> GetTrangThaiDuAnById(int id)
 {
     return(await _trangThaiDuAnRepository.GetByIdAsync(id));
 }
コード例 #14
0
 public async Task <User> FindByIdAsync(string userId, CancellationToken cancellationToken)
 {
     return(await provider.GetByIdAsync(userId, cancellationToken));
 }
コード例 #15
0
        public async Task <IActionResult> GetByIdAsync(int id)
        {
            var item = ToDoItemDTO.FromToDoItem(await _repository.GetByIdAsync <ToDoItem>(id));

            return(Ok(item));
        }
コード例 #16
0
 public async Task <Customer> GetByIdAsync(int id)
 {
     return(await _customerRepository.GetByIdAsync(id));
 }
コード例 #17
0
        /// <summary>
        /// Gets a measure dimension by identifier
        /// </summary>
        /// <param name="measureDimensionId">Measure dimension identifier</param>
        /// <returns>Measure dimension</returns>
        public virtual Task <MeasureDimension> GetMeasureDimensionById(string measureDimensionId)
        {
            string key = string.Format(CacheKey.MEASUREDIMENSIONS_BY_ID_KEY, measureDimensionId);

            return(_cacheBase.GetAsync(key, () => _measureDimensionRepository.GetByIdAsync(measureDimensionId)));
        }
コード例 #18
0
        /// <summary>
        /// Gets a store
        /// </summary>
        /// <param name="storeId">Store identifier</param>
        /// <returns>Store</returns>
        public virtual Task <Store> GetStoreById(string storeId)
        {
            string key = string.Format(CacheKey.STORES_BY_ID_KEY, storeId);

            return(_cacheBase.GetAsync(key, () => _storeRepository.GetByIdAsync(storeId)));
        }
コード例 #19
0
 /// <summary>
 /// Gets a category template
 /// </summary>
 /// <param name="categoryTemplateId">Category template identifier</param>
 /// <returns>Category template</returns>
 public virtual async Task <CategoryTemplate> GetCategoryTemplateByIdAsync(int categoryTemplateId)
 {
     return(await _categoryTemplateRepository.GetByIdAsync(categoryTemplateId, cache => default));
 }
コード例 #20
0
 /// <summary>
 /// Gets a tax rate
 /// </summary>
 /// <param name="taxRateId">Tax rate identifier</param>
 /// <returns>Tax rate</returns>
 public virtual Task <TaxRate> GetTaxRateById(string taxRateId)
 {
     return(_taxRateRepository.GetByIdAsync(taxRateId));
 }
コード例 #21
0
 private async Task <User> GetUserByIdAsync(long id)
 {
     return(await _repository.GetByIdAsync(id)
            ?? throw new NotFoundException($"User is not found with id {id}"));
 }
コード例 #22
0
ファイル: ProductTagService.cs プロジェクト: Sakchai/eStore
 /// <summary>
 /// Gets product tag
 /// </summary>
 /// <param name="productTagId">Product tag identifier</param>
 /// <returns>Product tag</returns>
 public virtual async Task<ProductTag> GetProductTagByIdAsync(int productTagId)
 {
     return await _productTagRepository.GetByIdAsync(productTagId, cache => default);
 }
コード例 #23
0
 /// <summary>
 /// Gets a product specification attribute mapping
 /// </summary>
 /// <param name="productSpecificationAttributeId">Product specification attribute mapping identifier</param>
 /// <returns>
 /// A task that represents the asynchronous operation
 /// The task result contains the product specification attribute mapping
 /// </returns>
 public virtual async Task <ProductSpecificationAttribute> GetProductSpecificationAttributeByIdAsync(int productSpecificationAttributeId)
 {
     return(await _productSpecificationAttributeRepository.GetByIdAsync(productSpecificationAttributeId));
 }
コード例 #24
0
 /// <summary>
 /// Gets product tag
 /// </summary>
 /// <param name="productTagId">Product tag identifier</param>
 /// <returns>Product tag</returns>
 public virtual Task <ProductTag> GetProductTagById(string productTagId)
 {
     return(_productTagRepository.GetByIdAsync(productTagId));
 }
コード例 #25
0
 /// <summary>
 /// Gets a product manufacturer mapping
 /// </summary>
 /// <param name="productManufacturerId">Product manufacturer mapping identifier</param>
 /// <returns>
 /// A task that represents the asynchronous operation
 /// The task result contains the product manufacturer mapping
 /// </returns>
 public virtual async Task <ProductManufacturer> GetProductManufacturerByIdAsync(int productManufacturerId)
 {
     return(await _productManufacturerRepository.GetByIdAsync(productManufacturerId, cache => default));
 }
コード例 #26
0
 /// <summary>
 /// Gets a country
 /// </summary>
 /// <param name="countryId">Country identifier</param>
 /// <returns>Country</returns>
 public virtual Task <Country> GetCountryById(string countryId)
 {
     return(_countryRepository.GetByIdAsync(countryId));
 }
コード例 #27
0
ファイル: OrderService.cs プロジェクト: smfichadiya/grandnode
 /// <summary>
 /// Gets an order
 /// </summary>
 /// <param name="orderId">The order identifier</param>
 /// <returns>Order</returns>
 public virtual Task <Order> GetOrderById(string orderId)
 {
     return(_orderRepository.GetByIdAsync(orderId));
 }
コード例 #28
0
 public virtual Task <CourseAction> GetById(string id)
 {
     return(_courseActionRepository.GetByIdAsync(id));
 }
コード例 #29
0
        public async Task <TalentProfileViewModel> GetTalentProfile(string Id)
        {
            //Your code here;
            User profile = null;

            profile = await _userRepository.GetByIdAsync(Id);

            if (profile != null)
            {
                var videoUrl = string.IsNullOrWhiteSpace(profile.VideoName)
                          ? ""
                          : await _fileService.GetFileURL(profile.VideoName, FileType.UserVideo);

                var CV_Url = string.IsNullOrWhiteSpace(profile.CvName)
                    ? "" : await _fileService.GetFileURL(profile.CvName, FileType.UserCV);

                var Languages = profile.Languages.Select((x) => ViewModalFromLanguage(x)).ToList();

                var Skills = profile.Skills.Select((x) => ViewModelFromSkill(x)).ToList();

                var Education = profile.Education.Select((x) => ViewModalFromEducation(x)).ToList();

                var Certificates = profile.Certifications.Select((x) => ViewModalFromCertification(x)).ToList();

                var Experience = profile.Experience.Select((x) => ViewModalFromExpericense(x)).ToList();

                var result = new TalentProfileViewModel
                {
                    Id                    = profile.Id,
                    FirstName             = profile.FirstName,
                    MiddleName            = profile.MiddleName,
                    LastName              = profile.LastName,
                    Gender                = profile.Gender,
                    Email                 = profile.Email,
                    Phone                 = profile.Phone,
                    MobilePhone           = profile.MobilePhone,
                    IsMobilePhoneVerified = profile.IsMobilePhoneVerified,
                    Address               = profile.Address,
                    Nationality           = profile.Nationality,
                    VisaStatus            = profile.VisaStatus,
                    VisaExpiryDate        = profile.VisaExpiryDate,
                    ProfilePhoto          = profile.ProfilePhoto,
                    ProfilePhotoUrl       = profile.ProfilePhotoUrl,
                    VideoName             = profile.VideoName,
                    VideoUrl              = videoUrl,
                    CvName                = profile.CvName,
                    CvUrl                 = CV_Url,
                    Summary               = profile.Summary,
                    Description           = profile.Description,
                    LinkedAccounts        = profile.LinkedAccounts,
                    JobSeekingStatus      = profile.JobSeekingStatus,
                    Languages             = Languages,
                    Skills                = Skills,
                    Education             = Education,
                    Certifications        = Certificates,
                    Experience            = Experience
                };
                return(result);
            }
            return(null);

            //throw new NotImplementedException();
        }
コード例 #30
0
 /// <summary>
 /// Gets a return request
 /// </summary>
 /// <param name="returnRequestId">Return request identifier</param>
 /// <returns>Return request</returns>
 public virtual Task <ReturnRequest> GetReturnRequestById(string returnRequestId)
 {
     return(_returnRequestRepository.GetByIdAsync(returnRequestId));
 }
コード例 #31
0
        /// <summary>
        /// Gets a measure unit by identifier
        /// </summary>
        /// <param name="measureUnitId">Measure unit identifier</param>
        /// <returns>Measure dimension</returns>
        public virtual Task <MeasureUnit> GetMeasureUnitById(string measureUnitId)
        {
            string key = string.Format(CacheKey.MEASUREUNITS_BY_ID_KEY, measureUnitId);

            return(_cacheBase.GetAsync(key, () => _measureUnitRepository.GetByIdAsync(measureUnitId)));
        }
コード例 #32
0
 public static async Task<bool> ExistsAsync<TEntity>(this IRepository<TEntity> repository, Guid id) where TEntity : Entity
     => (await repository.GetByIdAsync(id)) != null;