public void RightVersionNotFound() { // Arrange var unitOfWork = unitOfWorkMockSetup.Object; var contextManager = new TestContextManager(unitOfWork, unitOfWork); UserIdentificationMock.Setup(s => s.UserName).Returns("user"); VersioningManagerMock.Setup(s => s.GetVersionId <ServiceVersioned>(unitOfWork, _serviceId, null, false)) .Returns((Guid?)null); var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService, VersioningManager, UserInfoService, UserOrganizationChecker); var service = new ServiceService(contextManager, translationManagerMockSetup.Object, TranslationManagerVModel, Logger, serviceUtilities, DataUtils, CommonService, new VmOwnerReferenceLogic(), CacheManager.TypesCache, LanguageCache, PublishingStatusCache, VersioningManager, gdService, UserOrganizationChecker); // Act var result = service.SaveService(new VmOpenApiServiceInVersionBase { Id = _serviceId }, false, DefaultVersion, false); // Assert result.Should().BeNull(); translationManagerVModelMockSetup.Verify(x => x.Translate <IVmOpenApiServiceInVersionBase, ServiceVersioned>(It.IsAny <VmOpenApiServiceInVersionBase>(), unitOfWork), Times.Never()); }
/// <summary> /// Gets the delivery options information. /// </summary> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Response containing delivery options available for the channel.</returns> public async Task <ActionResult> GetDeliveryOptionsInfo(QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext); PagedResult <DeliveryOption> deliveryOptions = await orgUnitOperationsHandler.GetDeliveryOptionsInfo(queryResultSettings); return(this.Json(deliveryOptions.Results)); }
public async Task <bool> PostRemoveFactionAsync(string userId, bool canChangeAgain) { Uri requestUri = new Uri(App.Current.ServerAddress, "api/game/remove-faction") .AddParameter("userId", userId) .AddParameter("canChangeAgain", canChangeAgain.ToString()); return(await ServiceUtilities.SendSimpleHttpPostRequest(requestUri)); }
public async Task <bool> PostFactionAsync(string userId, string factionName) { Uri requestUri = new Uri(App.Current.ServerAddress, "api/game/faction") .AddParameter("userId", userId) .AddParameter("factionName", factionName); return(await ServiceUtilities.SendSimpleHttpPostRequest(requestUri)); }
public async Task <bool> PostRatingAsync(string userId, double rating) { Uri requestUri = new Uri(App.Current.ServerAddress, "api/game/rating") .AddParameter("userId", userId) .AddParameter("rating", rating.ToString()); return(await ServiceUtilities.SendSimpleHttpPostRequest(requestUri)); }
/// <summary> /// Gets the product availability. /// </summary> /// <param name="productIds">The product ids.</param> /// <param name="channelId">The channel identifier.</param> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Response containing available quantities for the listings inquired.</returns> public async Task <ActionResult> GetProductAvailability(IEnumerable <long> productIds, long channelId, QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); ProductOperationsHandler productOperationsHandler = new ProductOperationsHandler(ecommerceContext); PagedResult <ProductAvailableQuantity> productAvailableQuantities = await productOperationsHandler.GetProductAvailability(productIds, channelId, queryResultSettings); return(this.Json(productAvailableQuantities.Results)); }
/// <summary> /// Gets the products. /// </summary> /// <param name="productIds">The product ids.</param> /// <returns>Response containing simple products.</returns> public async Task <ActionResult> GetSimpleProducts(IEnumerable <long> productIds) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); ProductOperationsHandler productOperationsHandler = new ProductOperationsHandler(ecommerceContext); IEnumerable <SimpleProduct> simpleProducts = await productOperationsHandler.GetSimpleProducts(productIds); return(this.Json(simpleProducts)); }
/// <summary> /// Gets the loyalty cards. /// </summary> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Response containing the loyalty cards associated with the current user.</returns> public async Task <ActionResult> GetLoyaltyCards(QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); CustomerOperationsHandler customerOperationsHandler = new CustomerOperationsHandler(ecommerceContext); PagedResult <LoyaltyCard> loyaltyCards = await customerOperationsHandler.GetLoyaltyCards(queryResultSettings); return(this.Json(loyaltyCards.Results)); }
public async Task <bool> PostConfirmAsync(string userId, string pendingRideId) { var uri = new Uri(App.Current.ServerAddress, "api/rides/pending-ride/confirm") .AddParameter("userId", userId) .AddParameter("pendingRideId", pendingRideId); return(await ServiceUtilities.SendSimpleHttpPostRequest(uri)); }
async Task <bool> PostActiveRideMethod(string userId, string activeRideId, string resource) { var uri = new Uri(App.Current.ServerAddress, $"api/rides/active-ride/{resource}") .AddParameter("userId", userId) .AddParameter("activeRideId", activeRideId); return(await ServiceUtilities.SendSimpleHttpPostRequest(uri)); }
/// <summary> /// Gets the card types. /// </summary> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>A response containing collection of card types supported by channel..</returns> public async Task <ActionResult> GetCardTypes(QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext); PagedResult <CardTypeInfo> cardTypeInfoCollection = await orgUnitOperationsHandler.GetCardTypes(queryResultSettings); return(this.Json(cardTypeInfoCollection.Results)); }
/// <summary> /// Gets the channel tender types. /// </summary> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Tender types response.</returns> public async Task <ActionResult> GetChannelTenderTypes(QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext); PagedResult <TenderType> tenderTypes = await orgUnitOperationsHandler.GetTenderTypes(queryResultSettings); return(this.Json(tenderTypes.Results)); }
/// <summary> /// Gets the channel configuration. /// </summary> /// <returns>Response containing the channel configuration.</returns> public async Task <ActionResult> GetChannelConfiguration() { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext); ChannelConfiguration channelConfiguration = await orgUnitOperationsHandler.GetChannelConfiguration(); return(this.Json(channelConfiguration)); }
/// <summary> /// Gets the nearby stores. /// </summary> /// <param name="latitude">The latitude.</param> /// <param name="longitude">The longitude.</param> /// <param name="distance">The distance.</param> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Response containing nearby stores.</returns> public async Task <ActionResult> GetNearbyStores(decimal latitude, decimal longitude, int distance, QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext); PagedResult <OrgUnitLocation> orgUnitLocations = await orgUnitOperationsHandler.GetNearbyStores(latitude, longitude, distance, queryResultSettings); return(this.Json(orgUnitLocations.Results)); }
/// <summary> /// Gets the nearby stores with availability. /// </summary> /// <param name="latitude">The latitude.</param> /// <param name="longitude">The longitude.</param> /// <param name="searchRadius">The search radius.</param> /// <param name="itemUnits">The item units.</param> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Response containing stores with product availability.</returns> public async Task <ActionResult> GetNearbyStoresWithAvailability(decimal latitude, decimal longitude, double searchRadius, IEnumerable <ItemUnit> itemUnits, QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext); PagedResult <OrgUnitAvailability> orgUnitAvailabilities = await orgUnitOperationsHandler.GetNearbyStoresWithAvailability(latitude, longitude, searchRadius, itemUnits, queryResultSettings); return(this.Json(orgUnitAvailabilities.Results)); }
/// <summary> /// Gets the order history of a customer. /// </summary> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>A sakes order response.</returns> public async Task <ActionResult> GetOrderHistory(QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); CustomerOperationsHandler customerOperationsHandler = new CustomerOperationsHandler(ecommerceContext); PagedResult <SalesOrder> salesOrders = await customerOperationsHandler.GetOrderHistory(queryResultSettings); return(this.Json(salesOrders)); }
/// <summary> /// Generates the loyalty card identifier. /// </summary> /// <returns> /// Response containing a newly generated loyalty card. /// </returns> public async Task <ActionResult> GenerateLoyaltyCardId() { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); CustomerOperationsHandler customerOperationsHandler = new CustomerOperationsHandler(ecommerceContext); LoyaltyCard loyaltyCard = await customerOperationsHandler.GenerateLoyaltyCardId(); return(this.Json(loyaltyCard)); }
public async Task <bool> PostRequestCancelAsync(string userId, string requestId) { var uri = new Uri(App.Current.ServerAddress, "api/rides/request/cancel") .AddParameter("userId", userId) .AddParameter("requestId", requestId); return(await ServiceUtilities.SendSimpleHttpPostRequest(uri)); }
/// <summary> /// Updates the customer. /// </summary> /// <param name="customer">The customer.</param> /// <returns> /// The updated customer entity. /// </returns> public async Task <ActionResult> UpdateCustomer(Customer customer) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); CustomerOperationsHandler customerOperationsHandler = new CustomerOperationsHandler(ecommerceContext); Customer updatedCustomer = await customerOperationsHandler.UpdateCustomer(customer); return(this.Json(updatedCustomer)); }
/// <summary> /// Gets the sales order. /// </summary> /// <param name="salesOrderSearchCriteria">The sales order search criteria.</param> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>A response containing the sales orders inquired for.</returns> public async Task <ActionResult> GetSalesOrder(SalesOrderSearchCriteria salesOrderSearchCriteria, QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); SalesOrderOperationsHandler salesOrderOperationHandler = new SalesOrderOperationsHandler(ecommerceContext); PagedResult <SalesOrder> salesOrders = await salesOrderOperationHandler.GetSalesOrder(salesOrderSearchCriteria, queryResultSettings); return(this.Json(salesOrders.Results)); }
/// <summary> /// Gets the state province information. /// </summary> /// <param name="countryCode">The country code.</param> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>The states/provinces for the given country.</returns> public async Task <ActionResult> GetStateProvinceInfo(string countryCode, QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); RetailOperationsHandler retailOperationsHandler = new RetailOperationsHandler(ecommerceContext); PagedResult <StateProvinceInfo> stateProvinceInfoCollection = await retailOperationsHandler.GetStateProvinces(countryCode, queryResultSettings); return(this.Json(stateProvinceInfoCollection.Results)); }
/// <summary> /// Gets the gift card information. /// </summary> /// <param name="giftCardId">The gift card identifier.</param> /// <returns>A response containing gift card information.</returns> public async Task <ActionResult> GetGiftCardInformation(string giftCardId) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); RetailOperationsHandler retailOperationsHandler = new RetailOperationsHandler(ecommerceContext); GiftCard giftCard = await retailOperationsHandler.GetGiftCardInformation(giftCardId); return(this.Json(giftCard)); }
/// <summary> /// Gets the country region information. /// </summary> /// <param name="languageId">The language identifier.</param> /// <param name="queryResultSettings">The query result settings.</param> /// <returns>Country info response.</returns> public async Task <ActionResult> GetCountryRegionInfo(string languageId, QueryResultSettings queryResultSettings) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); RetailOperationsHandler retailOperationsHandler = new RetailOperationsHandler(ecommerceContext); PagedResult <CountryRegionInfo> countryRegionInfoCollection = await retailOperationsHandler.GetCountryRegionInfo(languageId, queryResultSettings); return(this.Json(countryRegionInfoCollection.Results)); }
/// <summary> /// Gets the loyalty card status. /// </summary> /// <param name="loyaltyCardNumbers">The loyalty card numbers.</param> /// <returns>Response containing the statuses of the specified loyalty card numbers.</returns> public async Task <ActionResult> GetLoyaltyCardStatus(IEnumerable <string> loyaltyCardNumbers) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); RetailOperationsHandler retailOperationsHandler = new RetailOperationsHandler(ecommerceContext); PagedResult <LoyaltyCard> loyaltyCards = await retailOperationsHandler.GetLoyaltyCardStatus(loyaltyCardNumbers); return(this.Json(loyaltyCards.Results)); }
/// <summary> /// Retrieves the card payment accept result. /// </summary> /// <param name="cardPaymentResultAccessCode">The card payment result access code.</param> /// <returns>Returns payment response.</returns> public async Task <ActionResult> RetrieveCardPaymentAcceptResult(string cardPaymentResultAccessCode) { EcommerceContext ecommerceContext = ServiceUtilities.GetEcommerceContext(this.HttpContext); RetailOperationsHandler retailOperationsHandler = new RetailOperationsHandler(ecommerceContext); CardPaymentAcceptResult cardPaymentAcceptResult = await retailOperationsHandler.RetrieveCardPaymentAcceptResult(cardPaymentResultAccessCode); return(this.Json(cardPaymentAcceptResult)); }
public void CanModify() { // Arrange var serviceId = Guid.NewGuid(); var channelId = Guid.NewGuid(); var organizationId = Guid.NewGuid(); var relation = new V7VmOpenApiServiceServiceChannelAstiInBase { ServiceId = serviceId.ToString(), ServiceChannelId = channelId.ToString() }; var unitOfWork = unitOfWorkMockSetup.Object; var contextManager = new TestContextManager(unitOfWork, unitOfWork); var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService, VersioningManager, UserInfoService, UserOrganizationChecker); ServiceServiceMock.Setup(s => s.GetServiceByIdSimple(serviceId, true)) .Returns(new VmOpenApiServiceVersionBase() { PublishingStatus = PublishingStatus.Published.ToString() }); ChannelServiceMock.Setup(s => s.GetServiceChannelByIdSimple(channelId, true)) .Returns(new VmOpenApiServiceChannel() { Id = channelId, IsVisibleForAll = false, OrganizationId = organizationId, ServiceChannelType = ServiceChannelTypeEnum.ServiceLocation.ToString(), Security = new VmSecurityOwnOrganization { IsOwnOrganization = true } }); //UserOrganizationServiceMock.Setup(s => s.GetAllUserOrganizations(unitOfWork)).Returns(new List<Guid>() { organizationId }); translationManagerVModelMockSetup.Setup(s => s.Translate <IVmOpenApiServiceServiceChannelInVersionBase, ServiceServiceChannel>(relation, unitOfWork)) .Returns(new ServiceServiceChannel()); var service = new ServiceAndChannelService(contextManager, translationManagerMockSetup.Object, translationManagerVModelMockSetup.Object, Logger, serviceUtilities, DataUtils, ServiceServiceMock.Object, ChannelService, PublishingStatusCache, VersioningManager, UserOrganizationChecker, CacheManager, UserOrganizationServiceMock.Object); // Act var result = service.SaveServicesAndChannels(new List <V7VmOpenApiServiceServiceChannelAstiInBase> { relation }); // Assert result.Should().NotBeNull(); var list = Assert.IsType <List <string> >(result); list.Count.Should().Be(1); list.FirstOrDefault().Should().EndWith("added or updated."); translationManagerVModelMockSetup.Verify(x => x.Translate <IVmOpenApiServiceServiceChannelInVersionBase, ServiceServiceChannel>(It.IsAny <VmOpenApiServiceServiceChannelInVersionBase>(), unitOfWork), Times.Once()); }
public void ASTIUpdate_RegularConnectionsNotDeleted() { // Arrange var serviceId = Guid.NewGuid(); var channelId = Guid.NewGuid(); var request = new V7VmOpenApiServiceAndChannelRelationAstiInBase { IsASTI = true, ServiceId = serviceId, ChannelRelations = new List <V7VmOpenApiServiceServiceChannelAstiInBase> { new V7VmOpenApiServiceServiceChannelAstiInBase { ServiceGuid = serviceId, ChannelGuid = channelId, } } }; var unitOfWork = unitOfWorkMockSetup.Object; var contextManager = new TestContextManager(unitOfWork, unitOfWork); var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService, VersioningManager, UserInfoService, UserOrganizationChecker); translationManagerVModelMockSetup.Setup(s => s.Translate <V7VmOpenApiServiceAndChannelRelationAstiInBase, Model.Models.Service>(request, unitOfWork)) .Returns(new Model.Models.Service() { Id = serviceId, ServiceServiceChannels = new List <ServiceServiceChannel> { new ServiceServiceChannel { IsASTIConnection = true, ServiceChannelId = channelId }, new ServiceServiceChannel { IsASTIConnection = false, ServiceChannelId = Guid.NewGuid() } } }); // repositories ConnectionRepoMock.Setup(c => c.All()).Returns(new List <ServiceServiceChannel>().AsQueryable()); DescriptionRepoMock.Setup(c => c.All()).Returns(new List <ServiceServiceChannelDescription>().AsQueryable()); var service = new ServiceAndChannelService(contextManager, translationManagerMockSetup.Object, translationManagerVModelMockSetup.Object, Logger, serviceUtilities, DataUtils, ServiceService, ChannelService, PublishingStatusCache, VersioningManager, UserOrganizationChecker, CacheManager, UserOrganizationService); // Act var result = service.SaveServiceConnections(request, DefaultVersion); // Assert // We are not testing method GetServiceById so we expect result to be null. result.Should().BeNull(); translationManagerVModelMockSetup.Verify(t => t.Translate <V7VmOpenApiServiceAndChannelRelationAstiInBase, Model.Models.Service>(It.IsAny <V7VmOpenApiServiceAndChannelRelationAstiInBase>(), unitOfWork), Times.Once()); ConnectionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannel>()), Times.Never()); DescriptionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannelDescription>()), Times.Never()); }
public static POIObject GetPOIObject(string keyWord, string pageIndex, string pageSize) { string POIUrl = SystemUtility.Config.POIUrl; string postUrl = string.Format(POIUrl, keyWord, pageIndex, pageSize); string returnJson = ServiceUtilities.Get(postUrl, Encoding.UTF8); POIObject POIObj = Newtonsoft.Json.JsonConvert.DeserializeObject <POIObject>(returnJson); return(POIObj); }
public static IServiceCollection TryAddLazySingleton <TService, TImpl>(this IServiceCollection collection) where TService : class where TImpl : TService { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } collection.TryAdd(ServiceUtilities.LazyDescribe(typeof(TService), typeof(TImpl), ServiceLifetime.Singleton)); return(collection); }
private DataAccess.Services.OrganizationService Arrange(List <OrganizationVersioned> list = null) { var organizationList = list ?? _organizationList; var publishedOrganization = organizationList.Where(o => o.PublishingStatusId == PublishedId).FirstOrDefault(); var id = publishedOrganization.Id; var rootId = publishedOrganization.UnificRootId; unitOfWorkMockSetup.Setup(uw => uw.ApplyIncludes( It.IsAny <IQueryable <OrganizationVersioned> >(), It.IsAny <Func <IQueryable <OrganizationVersioned>, IQueryable <OrganizationVersioned> > >(), It.IsAny <bool>() )).Returns((IQueryable <OrganizationVersioned> orgList, Func <IQueryable <OrganizationVersioned>, IQueryable <OrganizationVersioned> > func, bool applyfilters) => { return(orgList); }); var unitOfWork = unitOfWorkMockSetup.Object; var contextManager = new TestContextManager(unitOfWork, unitOfWork); var serviceUtilities = new ServiceUtilities(UserIdentification, LockingManager, contextManager, UserOrganizationService, VersioningManager, UserInfoService, UserOrganizationChecker); translationManagerMockSetup.Setup(t => t.Translate <OrganizationVersioned, VmOpenApiOrganizationVersionBase>(It.IsAny <OrganizationVersioned>())) .Returns((OrganizationVersioned org) => { if (org == null) { return(null); } return(new VmOpenApiOrganizationVersionBase { Id = org.UnificRootId, Modified = org.Modified, PublishingStatus = TypeCache.GetByValue <PublishingStatusType>(org.PublishingStatusId) }); }); var translationManagerMock = translationManagerMockSetup.Object; VersioningManagerMock.Setup(s => s.GetVersionId <OrganizationVersioned>(unitOfWork, rootId, PublishingStatus.Published, true)).Returns(id); // repositories OrganizationRepoMock.Setup(g => g.All()).Returns(organizationList.AsQueryable()); OrganizationNameRepoMock.Setup(m => m.All()).Returns(Enumerable.Empty <OrganizationName>().AsQueryable()); var serviceNameRepoMock = new Mock <IServiceNameRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceNameRepository>()).Returns(serviceNameRepoMock.Object); var organizationServiceRepoMock = new Mock <IOrganizationServiceRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IOrganizationServiceRepository>()).Returns(organizationServiceRepoMock.Object); var serviceRepoMock = new Mock <IServiceVersionedRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceVersionedRepository>()).Returns(serviceRepoMock.Object); var serviceProducerRepoMock = new Mock <IServiceProducerOrganizationRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceProducerOrganizationRepository>()).Returns(serviceProducerRepoMock.Object); return(new DataAccess.Services.OrganizationService(contextManager, translationManagerMock, TranslationManagerVModel, Logger, OrganizationLogic, serviceUtilities, DataUtils, CommonService, AddressService, PublishingStatusCache, LanguageCache, VersioningManager, UserOrganizationChecker, CacheManager.TypesCache)); }