Esempio n. 1
0
 //public IEnumerable<IEnumerable<Match>> this[params Guid[] seriesIds]
 //{
 //    get
 //    {
 //        List<Guid> matchScheduleIds = new List<Guid>();
 //        List<List<Match>> allschedules = new List<List<Match>>();
 //        foreach (var seriesId in seriesIds)
 //        {
 //            if (this.matchSchedule.TryGetValue(seriesId, out matchScheduleIds))
 //            {
 //                foreach (var matchId in matchScheduleIds)
 //                {
 //                }
 //            }
 //        }
 //    }
 //}
 public void UpdateSchedule(Guid seriesId)
 {
     this.allMatches[seriesId] =
         DomainService.GetAllMatches().Where(x => x.SeriesId == seriesId && x.HomeTeamId
                                             == this.teamId || x.AwayTeamId
                                             == this.teamId).ToList();
 }
        private DomainService GetDomainService(object instance, WcfDomainServiceContext context)
        {
            // create and initialize the DomainService for this request
            DomainServiceBehavior.DomainServiceInstanceInfo instanceInfo =
                (DomainServiceBehavior.DomainServiceInstanceInfo)instance;

            try
            {
                DomainService domainService = DomainService.Factory.CreateDomainService(instanceInfo.DomainServiceType, context);
                instanceInfo.DomainServiceInstance = domainService;
                return(domainService);
            }
            catch (TargetInvocationException tie)
            {
                if (tie.InnerException != null)
                {
                    throw ServiceUtility.CreateFaultException(tie.InnerException, context.DisableStackTraces);
                }

                throw ServiceUtility.CreateFaultException(tie, context.DisableStackTraces);
            }
            catch (Exception ex)
            {
                if (ex.IsFatal())
                {
                    throw;
                }
                throw ServiceUtility.CreateFaultException(ex, context.DisableStackTraces);
            }
        }
Esempio n. 3
0
            protected async override ValueTask <object> InvokeCoreAsync(DomainService instance, object[] inputs, bool disableStackTraces)
            {
                ServiceInvokeResult invokeResult;

                try
                {
                    InvokeDescription invokeDescription = new InvokeDescription(this.operation, inputs);
                    invokeResult = await instance.InvokeAsync(invokeDescription, CancellationToken.None).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    throw ServiceUtility.CreateFaultException(ex, disableStackTraces);
                }

                if (invokeResult.HasValidationErrors)
                {
                    throw ServiceUtility.CreateFaultException(invokeResult.ValidationErrors, disableStackTraces);
                }
                else
                {
                    return(invokeResult.Result);
                }
            }
Esempio n. 4
0
        public void Returns_Correct_True_Result(string nameservers)
        {
            // Arrange
            var domainFactory           = new Mock <IDomainFactory>();
            var brandviserData          = new Mock <IBrandviserData>();
            var dateTimeProvider        = new Mock <IDateTimeProvider>();
            var whois                   = new Mock <IWhois>();
            var txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var mockedDomainsRepository = new Mock <IEfRepository <Domain> >();

            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);
            mockedDomainsRepository.Setup(d => d.All).Returns(new List <Domain>()
            {
                new Domain()
                {
                    Name = "name"
                }
            }.AsQueryable());
            whois.Setup(w => w.LookupDotComDomain(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()))
            .Returns(nameservers);

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            var domainIsVerified = domainService.VerifyDomainNameNameservers("name", "nameserver1", "nameserver2");

            // Assert
            Assert.IsTrue(domainIsVerified);
        }
        private DomainService GetDomainService(object instance)
        {
            // create and initialize the DomainService for this request
            DomainServiceBehavior.DomainServiceInstanceInfo instanceInfo =
                (DomainServiceBehavior.DomainServiceInstanceInfo)instance;

            IServiceProvider     serviceProvider = (IServiceProvider)OperationContext.Current.Host;
            DomainServiceContext context         = new DomainServiceContext(serviceProvider, this.operationType);

            try
            {
                DomainService domainService = DomainService.Factory.CreateDomainService(instanceInfo.DomainServiceType, context);
                instanceInfo.DomainServiceInstance = domainService;
                return(domainService);
            }
            catch (TargetInvocationException tie)
            {
                if (tie.InnerException != null)
                {
                    throw ServiceUtility.CreateFaultException(tie.InnerException);
                }

                throw ServiceUtility.CreateFaultException(tie);
            }
            catch (Exception ex)
            {
                if (ex.IsFatal())
                {
                    throw;
                }
                throw ServiceUtility.CreateFaultException(ex);
            }
        }
        /// <summary>
        /// 执行事件
        /// </summary>
        protected virtual void ExecutEvent(IList <IUnitofwork> unitofworks, EventHandleSequenceType sequenceType, TEntityType info)
        {
            if (EventHandles == null || info == null)
            {
                return;
            }
            DomainService.SetItemLoaders(info);
            var handles = EventHandles.GetHandles(sequenceType, info.EventName);

            if (handles == null)
            {
                return;
            }
            foreach (var eventHandle in handles)
            {
                var args = new EventHandleArgs <TEntityType>
                {
                    Entity      = info,
                    Unitofworks = unitofworks,
                    Sender      = eventHandle
                };
                if (eventHandle.IsAsynchronization)
                {
                    eventHandle.Handle.BeginInvoke(args, null, null);
                }
                else
                {
                    eventHandle.Handle(args);
                }
            }
        }
Esempio n. 7
0
        public void Call_DomainRepository_Once()
        {
            // Arrange
            var domainFactory           = new Mock <IDomainFactory>();
            var brandviserData          = new Mock <IBrandviserData>();
            var dateTimeProvider        = new Mock <IDateTimeProvider>();
            var whois                   = new Mock <IWhois>();
            var txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var mockedDomainsRepository = new Mock <IEfRepository <Domain> >();

            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);
            mockedDomainsRepository.Setup(d => d.All).Returns(new List <Domain>()
            {
                new Domain()
                {
                    Name = "name"
                }
            }.AsQueryable());
            whois.Setup(w => w.LookupDotComDomain(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()))
            .Returns("returned value");

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            domainService.VerifyDomainNameNameservers("name", "nameserver1", "nameserver2");

            // Assert
            mockedDomainsRepository.Verify(d => d.All, Times.Once());
        }
Esempio n. 8
0
        public ActionResult Users(FormCollection formCollection)
        {
            var securityService  = new DomainService();
            var usersInformation = securityService.GetEntities <HospitalManagementSystemContext, Person>(formCollection["usernameSearch"], formCollection["emailSearch"], null);

            return(View(new Tuple <List <Person>, bool>(usersInformation, true)));
        }
Esempio n. 9
0
        public void Call_Domain_Repository_Once()
        {
            // Arrange
            var     domainFactory           = new Mock <IDomainFactory>();
            var     brandviserData          = new Mock <IBrandviserData>();
            var     dateTimeProvider        = new Mock <IDateTimeProvider>();
            var     whois                   = new Mock <IWhois>();
            var     txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var     mockedDomainsRepository = new Mock <IEfRepository <Domain> >();
            var     name   = "name";
            decimal?price  = 1;
            var     domain = new Domain()
            {
                Name = name
            };
            var collection = new List <Domain>();

            collection.Add(domain);

            mockedDomainsRepository.Setup(r => r.All).Returns(collection.AsQueryable <Domain>());
            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            domainService.ApproveDomain(name, price);

            // Assert
            mockedDomainsRepository.Verify(d => d.All, Times.Once());
        }
        /// <summary>
        /// Helper method performs a query operation against a given proxy instance.
        /// </summary>
        /// <param name="domainService">The type of <see cref="DomainService"/> to perform this query operation against.</param>
        /// <param name="context">The current context.</param>
        /// <param name="domainServiceInstances">The list of tracked <see cref="DomainService"/> instances that any newly created
        /// <see cref="DomainServices"/> will be added to.</param>
        /// <param name="queryName">The name of the query to invoke.</param>
        /// <param name="parameters">The query parameters.</param>
        /// <returns>The query results. May be null if there are no query results.</returns>
        /// <exception cref="ArgumentNullException">if <paramref name="context"/> is null.</exception>
        /// <exception cref="ArgumentNullException">if <paramref name="queryName"/> is null or an empty string.</exception>
        /// <exception cref="InvalidOperationException">if no match query operation exists on the <paramref name="context"/>.</exception>
        /// <exception cref="OperationException">if operation errors are thrown during execution of the query operation.</exception>
        public static IEnumerable Query(Type domainService, DomainServiceContext context, IList <DomainService> domainServiceInstances, string queryName, object[] parameters)
        {
            context = new DomainServiceContext(context, DomainOperationType.Query);
            DomainService            service            = CreateDomainServiceInstance(domainService, context, domainServiceInstances);
            DomainServiceDescription serviceDescription = DomainServiceDescription.GetDescription(service.GetType());
            DomainOperationEntry     queryOperation     = serviceDescription.GetQueryMethod(queryName);

            if (queryOperation == null)
            {
                string errorMessage =
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resource.DomainServiceProxy_QueryOperationNotFound,
                        queryName,
                        domainService);

                throw new InvalidOperationException(errorMessage);
            }

            int totalCount;
            IEnumerable <ValidationResult> validationErrors;

            object[]         parameterValues  = parameters ?? new object[0];
            QueryDescription queryDescription = new QueryDescription(queryOperation, parameterValues);

            IEnumerable result = service.Query(queryDescription, out validationErrors, out totalCount);

            if (validationErrors != null && validationErrors.Any())
            {
                IEnumerable <ValidationResultInfo> operationErrors = validationErrors.Select(ve => new ValidationResultInfo(ve.ErrorMessage, ve.MemberNames));
                throw new OperationException(Resource.DomainServiceProxy_OperationError, operationErrors);
            }

            return(result);
        }
Esempio n. 11
0
        public void Call_DateTimeProvider_GetCurrentTime_Once()
        {
            // Arrange
            var domainFactory     = new Mock <IDomainFactory>();
            var bradviserData     = new Mock <IBrandviserData>();
            var dateTimeProvider  = new Mock <IDateTimeProvider>();
            var whois             = new Mock <IWhois>();
            var txtRecordsChecker = new Mock <ITxtRecordsChecker>();
            var domainsRepository = new Mock <IEfRepository <Domain> >();

            bradviserData.Setup(d => d.Domains).Returns(domainsRepository.Object);

            var domainService = new DomainService(bradviserData.Object, domainFactory.Object,
                                                  dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            dateTimeProvider.Setup(d => d.GetCurrentTime()).Returns(new DateTime(17, 1, 1));
            domainFactory.Setup(d =>
                                d.CreateDomain(
                                    It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <DateTime>()))
            .Returns(new Domain());
            // Act
            domainService.AddDomain("name", "description", "userId");

            // Assert
            dateTimeProvider.Verify(d => d.GetCurrentTime(), Times.Once());
        }
Esempio n. 12
0
 public void Initialize()
 {
     this.dummySeries          = new DummySeries();
     this.dummyPlayer          = DomainService.FindPlayerById(this.dummySeries.DummyTeams.DummyTeamOne.PlayerIds.First());
     this.dummyPlayerDuplicate = new Player(this.dummyPlayer.Name, this.dummyPlayer.DateOfBirth,
                                            this.dummyPlayer.Position, this.dummyPlayer.Status, this.dummyPlayer.Id);
 }
Esempio n. 13
0
        public void Call_BrandviserData_SaveChanges_Once()
        {
            // Arrange
            var domainFactory           = new Mock <IDomainFactory>();
            var brandviserData          = new Mock <IBrandviserData>();
            var dateTimeProvider        = new Mock <IDateTimeProvider>();
            var whois                   = new Mock <IWhois>();
            var txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var mockedDomainsRepository = new Mock <IEfRepository <Domain> >();
            var domain                  = new Domain();

            mockedDomainsRepository.Setup(m => m.GetById(It.IsAny <int>())).Returns(domain);
            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);

            var actualDomainId = 1;

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            domainService.UpdateDomainToBought(actualDomainId);

            // Assert
            brandviserData.Verify(b => b.SaveChanges(), Times.Once());
        }
Esempio n. 14
0
        public void Call_Domain_Repository_Once()
        {
            // Arrange
            var domainFactory           = new Mock <IDomainFactory>();
            var brandviserData          = new Mock <IBrandviserData>();
            var dateTimeProvider        = new Mock <IDateTimeProvider>();
            var whois                   = new Mock <IWhois>();
            var txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var mockedDomainsRepository = new Mock <IEfRepository <Domain> >();
            var name = "test name";

            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);
            mockedDomainsRepository.Setup(d => d.All).Returns(new List <Domain>()
            {
                new Domain()
                {
                    Name = name
                }
            }.AsQueryable());

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            domainService.PublishDomain(name);

            // Assert
            mockedDomainsRepository.Verify(d => d.All, Times.Once());
        }
Esempio n. 15
0
 public void InsertContract(Contract contract)
 {
     using (DomainService service = new DomainService())
     {
         service.InsertContract(contract);
     }
 }
Esempio n. 16
0
        public void Call_DateTimeProvider_GetCurrentTime_Once()
        {
            // Arrange
            var domainFactory           = new Mock <IDomainFactory>();
            var brandviserData          = new Mock <IBrandviserData>();
            var dateTimeProvider        = new Mock <IDateTimeProvider>();
            var whois                   = new Mock <IWhois>();
            var txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var mockedDomainsRepository = new Mock <IEfRepository <Domain> >();
            var name   = "name";
            var domain = new Domain()
            {
                Name = name
            };
            var collection = new List <Domain>();

            collection.Add(domain);

            mockedDomainsRepository.Setup(r => r.All).Returns(collection.AsQueryable <Domain>());
            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);
            decimal?ownerPrice  = 1;
            var     description = "description";

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            domainService.EditDomainOwnerPriceAndDescription(name, ownerPrice, description);

            // Assert
            dateTimeProvider.Verify(d => d.GetCurrentTime(), Times.Once());
        }
Esempio n. 17
0
 public void InsertAgreement(Agreement agreement)
 {
     using (DomainService service = new DomainService())
     {
         service.InsertAgreement(agreement);
     }
 }
Esempio n. 18
0
 public void DeleteAgreement(Agreement agreement)
 {
     using (DomainService service = new DomainService())
     {
         service.DeleteAgreement(agreement);
     }
 }
Esempio n. 19
0
 public void UpdateDocumentType(DocumentType currentDocumentType)
 {
     using (DomainService service = new DomainService())
     {
         service.UpdateDocumentType(currentDocumentType);
     }
 }
Esempio n. 20
0
 public void DeleteDocumentType(DocumentType documentType)
 {
     using (DomainService service = new DomainService())
     {
         service.DeleteDocumentType(documentType);
     }
 }
Esempio n. 21
0
 public void DeleteContract_Document(Contract_Document contract_Document)
 {
     using (DomainService service = new DomainService())
     {
         service.DeleteContract_Document(contract_Document);
     }
 }
Esempio n. 22
0
 public void InsertDocumentType(DocumentType documentType)
 {
     using (DomainService service = new DomainService())
     {
         service.InsertDocumentType(documentType);
     }
 }
Esempio n. 23
0
 /// <summary>
 ///     Registers the Patient component service classes. Operation in the DI container
 /// </summary>
 /// <param name="services">Specifies the contract for a collection of service descriptors</param>
 /// <returns></returns>
 public static IServiceCollection Register(this IServiceCollection services)
 {
     ApplicationService.Register(services);
     DomainService.Register(services);
     InfrastructureService.Register(services);
     return(services);
 }
Esempio n. 24
0
        /// <summary>
        /// Creates a <see cref="DomainService"/> instance for a given <see cref="DomainServiceContext"/>.
        /// </summary>
        /// <param name="domainService">The <see cref="DomainService"/> <see cref="Type"/> to create.</param>
        /// <param name="context">The <see cref="DomainServiceContext"/> to provide to the <see cref="DomainService.Factory"/>.</param>
        /// <param name="domainServiceInstances">The list used to track <see cref="DomainService"/> instances.</param>
        /// <returns>A <see cref="DomainService"/> instance.</returns>
        private static DomainService CreateDomainServiceInstance(Type domainService, DomainServiceContext context, IList <DomainService> domainServiceInstances)
        {
            DomainService service = DomainService.Factory.CreateDomainService(domainService, context);

            domainServiceInstances.Add(service);
            return(service);
        }
        public async virtual Task <Result> TriggerActionAsync(object id, ActionDto action, string triggeredBy, CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await DomainService.TriggerActionAsync(id, action.Action, triggeredBy, cancellationToken).ConfigureAwait(false);

            if (result.IsFailure)
            {
                switch (result.ErrorType)
                {
                case ErrorType.ObjectValidationFailed:
                    return(result);

                case ErrorType.DatabaseValidationFailed:
                    return(result);

                case ErrorType.ObjectDoesNotExist:
                    return(result);

                case ErrorType.ConcurrencyConflict:
                    return(result);

                default:
                    throw new ArgumentException();
                }
            }

            return(Result.Ok());
        }
Esempio n. 26
0
 public void DeleteContract(Contract contract)
 {
     using (DomainService service = new DomainService())
     {
         service.UpdateContract(contract);
     }
 }
Esempio n. 27
0
        public ActionResult ChangeGeneratedPassword(Person person, string returnUrl)
        {
            person.Error = string.Empty;

            var passwordManager = new PasswordManager();
            var changePassword  = passwordManager.ChangePassword(person);

            if (changePassword.Item1)
            {
                var service = new DomainService();

                person = service.GetEntity <HospitalManagementSystemContext, Person>(person.UserName, null);
                person.PasswordChanged = true;
                service.SaveEntity <HospitalManagementSystemContext, Person>(person, UserId, null);

                FormsAuthentication.SetAuthCookie(person.UserName, false);

                if (!string.IsNullOrWhiteSpace(returnUrl))
                {
                    return(Redirect(returnUrl));
                }

                return(RedirectToAction("Profile", "Account"));
            }

            person.Error = changePassword.Item2;
            return(View(person));
        }
        /// <summary>
        /// 执行事件。
        /// </summary>
        /// <param name="args">参数数组。</param>
        /// <returns>执行是否成功。</returns>
        /// <remarks>
        /// <para>孙涛</para>
        /// <para>2015/8/17</para>
        /// </remarks>
        public virtual bool Execute(object[] args)
        {
            try
            {
                int arg   = (args == null || args.Length == 0) ? 100 : Convert.ToInt32(args[0]);
                int count = arg > 0 ? arg : 100;
                EnsureOpenQueue();
                var infos = new List <KeyEntity>();

                KeyEntity info = null;
                while ((info = QueueRepository.Pop <KeyEntity>(QueueName)) != null)
                {
                    infos.Add(info);
                    if (infos.Count > count)
                    {
                        break;
                    }
                }

                var unitofworks = DomainService.Handle <KeyEntity>(infos);
                return(Commit(unitofworks));
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 29
0
        public void Change_Domain_Status_To_4Published()
        {
            // Arrange
            var domainFactory           = new Mock <IDomainFactory>();
            var brandviserData          = new Mock <IBrandviserData>();
            var dateTimeProvider        = new Mock <IDateTimeProvider>();
            var whois                   = new Mock <IWhois>();
            var txtRecordsChecker       = new Mock <ITxtRecordsChecker>();
            var mockedDomainsRepository = new Mock <IEfRepository <Domain> >();
            var name       = "test name";
            var collection = new List <Domain>()
            {
                new Domain()
                {
                    Name = name
                }
            };

            brandviserData.Setup(b => b.Domains).Returns(mockedDomainsRepository.Object);
            mockedDomainsRepository.Setup(d => d.All).Returns(collection.AsQueryable());

            var domainService = new DomainService(brandviserData.Object,
                                                  domainFactory.Object, dateTimeProvider.Object, whois.Object, txtRecordsChecker.Object);

            // Act
            domainService.PublishDomain(name);

            // Assert
            Assert.That(collection[0].StatusId == 4);
        }
Esempio n. 30
0
 public void UpdateContract(Contract currentContract)
 {
     using (DomainService service = new DomainService())
     {
         service.UpdateContract(currentContract);
     }
 }
        /// <summary>
        /// Process the specified change set operations and return the results.
        /// </summary>
        /// <param name="domainService">The domain service that will process the changeset.</param>
        /// <param name="changeSetEntries">The change set entries to be processed.</param>
        /// <returns>Collection of results from the submit operation.</returns>
        public static IEnumerable<ChangeSetEntry> Process(DomainService domainService, IEnumerable<ChangeSetEntry> changeSetEntries)
        {
            ChangeSet changeSet = CreateChangeSet(changeSetEntries);
            
            domainService.Submit(changeSet);

            // Process the submit results and build the result list to be sent back
            // to the client
            return GetSubmitResults(changeSet);
        }
        public void WhenGettingEntity_ThenReturnsCorrectEntity()
        {
            // Arrange
            var repositoryMock = new Mock<IDomainRepository>();
            Domain newEntity = DefaultModelHelper.DummyPopulatedDomain();

            repositoryMock.Setup(repo => repo.GetById(It.IsAny<int>())).Returns(newEntity);

            // Act
            var services = new DomainService(repositoryMock.Object, new Mock<IUnitOfWork>().Object);
            Domain returnedEntity = services.GetById(1);

            // Assert
            Assert.NotNull(returnedEntity);
            Assert.Equal("HostHeader", returnedEntity.HostHeader);
        }
        public OperationContext(DomainServiceContext domainServiceContext, DomainService domainService, DomainServiceDescription domainServiceDescription)
        {
            if (domainServiceContext == null)
            {
                throw new ArgumentNullException("domainServiceContext");
            }
            if (domainService == null)
            {
                throw new ArgumentNullException("domainService");
            }
            if (domainServiceDescription == null)
            {
                throw new ArgumentNullException("domainServiceDescription");
            }

            this._domainServiceContext = domainServiceContext;
            this._domainService = domainService;
            this._domainServiceDescription = domainServiceDescription;
        }
 private void InitializeServices()
 {
     this.domainService = new DomainService(this.domainRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.clientAssetConfigService = new ClientAssetConfigService(
         this.clientAssetConfigRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.clientAssetService = new ClientAssetService(
         this.clientAssetRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.clientAssetTypeService = new ClientAssetTypeService(
         this.clientAssetTypeRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.pageService = new PageService(this.pageRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.pageTemplateService = new PageTemplateService(
         this.pageTemplateRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.pageTemplateZoneMapService =
         new PageTemplateZoneMapService(
             this.pageTemplateZoneMapRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.pageZoneService = new PageZoneService(
         this.pageZoneRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.partService = new PartService(this.partRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.partTypeService = new PartTypeService(
         this.partTypeRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.seoDecoratorService = new SeoDecoratorService(
         this.seoDecoratorRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.userService = new UserService(this.userRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
     this.partContainerService = new PartContainerService(
         this.partContainerRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
 }
Esempio n. 35
0
 public int AuthenticateToDomain( string DomainID,
    string Password)
 {
     Store store = Store.GetStore();
        Domain domain = store.GetDomain(DomainID);
        if(domain == null)
     throw new Exception("ERROR:Invalid Domain ID");
        Member member = domain.GetCurrentMember();
        if(member == null)
     throw new Exception("ERROR:Unable locate user");
        DomainService domainSvc = new DomainService();
        Uri uri = DomainProvider.ResolveLocation(DomainID);
        if (uri == null)
     throw new Exception("ERROR:No host address for domain");
        domainSvc.Url = uri.ToString() + "/DomainService.asmx";
        domainSvc.Credentials =
     new NetworkCredential(member.Name, Password);
        try
        {
     domainSvc.GetDomainInfo(member.UserID);
        }
        catch(WebException webEx)
        {
     if (webEx.Status == System.Net.WebExceptionStatus.ProtocolError ||
      webEx.Status == System.Net.WebExceptionStatus.TrustFailure)
     {
      throw new Exception("ERROR: Invalid Credentials");
     }
     else if (webEx.Status == System.Net.WebExceptionStatus.ConnectFailure)
     {
      throw new Exception("ERROR: Domain Connection failed");
     }
     else
      throw webEx;
        }
        return 0;
 }
 public void ReleaseDomainService(DomainService domainService)
 {
     domainService.Dispose();
 }
        /// <summary>
        /// Validate the current request.
        /// </summary>
        /// <param name="domainService">Domain service instance for which request was sent.</param>
        private static void VerifyRequest(DomainService domainService)
        {
            EnableClientAccessAttribute ecaAttribute = (EnableClientAccessAttribute)TypeDescriptor.GetAttributes(domainService)[typeof(EnableClientAccessAttribute)];
            System.Diagnostics.Debug.Assert(ecaAttribute != null, "The OData Endpoint shouldn't be created if EnableClientAccess attribute is missing on the domain service type.");

            if (ecaAttribute.RequiresSecureEndpoint)
            {
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Request.IsSecureConnection)
                    {
                        return;
                    }
                }
                else if (OperationContext.Current != null)
                {
                    // DEVNOTE(wbasheer): See what the RIA people do here and match.
                }

                throw new DomainDataServiceException((int)HttpStatusCode.Forbidden, Resource.DomainDataService_Enable_Client_Access_Require_Secure_Connection);
            }
        }
 /// <summary>
 /// Invokes this <see cref="DomainOperationEntry" />.
 /// </summary>
 /// <param name="domainService">The <see cref="DomainService"/> instance the operation is being invoked on.</param>
 /// <param name="parameters">The parameters to pass to the method.</param>
 /// <returns>The return value of the invoked method.</returns>
 public override object Invoke(DomainService domainService, object[] parameters)
 {
     return this._method(domainService, parameters);
 }
 /// <summary>
 /// Releases an existing <see cref="DomainService" /> instance.
 /// </summary>
 /// <param name="domainService">The <see cref="DomainService" /> instance to release.</param>
 public void ReleaseDomainService(DomainService domainService)
 {
     RequestLifetimeScope.Disposer.AddInstanceForDisposal(domainService);
 }