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); }
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); }
public async Task <TEntity> GetByIdAsync(int Id) { return(await _repository.GetByIdAsync(Id)); }
/// <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)); }
/// <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)); }
/// <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)); }
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); }
/// <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)); }
/// <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)); }
/// <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)); }
public virtual async Task <TEntity> FindByIdAsync(CancellationToken cancellationToken, object id) { return(await _repository.GetByIdAsync(cancellationToken, id)); }
/// <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))); }
public async Task <TrangThaiDuAn> GetTrangThaiDuAnById(int id) { return(await _trangThaiDuAnRepository.GetByIdAsync(id)); }
public async Task <User> FindByIdAsync(string userId, CancellationToken cancellationToken) { return(await provider.GetByIdAsync(userId, cancellationToken)); }
public async Task <IActionResult> GetByIdAsync(int id) { var item = ToDoItemDTO.FromToDoItem(await _repository.GetByIdAsync <ToDoItem>(id)); return(Ok(item)); }
public async Task <Customer> GetByIdAsync(int id) { return(await _customerRepository.GetByIdAsync(id)); }
/// <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))); }
/// <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))); }
/// <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)); }
/// <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)); }
private async Task <User> GetUserByIdAsync(long id) { return(await _repository.GetByIdAsync(id) ?? throw new NotFoundException($"User is not found with id {id}")); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
public virtual Task <CourseAction> GetById(string id) { return(_courseActionRepository.GetByIdAsync(id)); }
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(); }
/// <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)); }
/// <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))); }
public static async Task<bool> ExistsAsync<TEntity>(this IRepository<TEntity> repository, Guid id) where TEntity : Entity => (await repository.GetByIdAsync(id)) != null;