コード例 #1
0
        public override ActionResult Create()
        {
            ContactTypeService ct = new ContactTypeService();

            ViewBag.ContactTypeId = new SelectList(ct.ListAll().OrderBy(c => c.Name), "Id", "Name");
            return(View());
        }
コード例 #2
0
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _contactTypeService = (ContactTypeService)ScopedServices.GetRequiredService(typeof(ContactTypeService));

            Items = await _contactTypeService.GetAllActive().ToListAsync();
        }
コード例 #3
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IContactTypeRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ContactType>(null));
            var service = new ContactTypeService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLContactTypeMapperMock,
                                                 mock.DALMapperMockFactory.DALContactTypeMapperMock,
                                                 mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                 mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            ApiContactTypeResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #4
0
        public async void BusinessEntityContacts_Not_Exists()
        {
            var mock = new ServiceMockFacade <IContactTypeRepository>();

            mock.RepositoryMock.Setup(x => x.BusinessEntityContacts(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <BusinessEntityContact> >(new List <BusinessEntityContact>()));
            var service = new ContactTypeService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLContactTypeMapperMock,
                                                 mock.DALMapperMockFactory.DALContactTypeMapperMock,
                                                 mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                 mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            List <ApiBusinessEntityContactResponseModel> response = await service.BusinessEntityContacts(default(int));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.BusinessEntityContacts(default(int), It.IsAny <int>(), It.IsAny <int>()));
        }
コード例 #5
0
        public async void ByName_Exists()
        {
            var mock   = new ServiceMockFacade <IContactTypeRepository>();
            var record = new ContactType();

            mock.RepositoryMock.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult(record));
            var service = new ContactTypeService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLContactTypeMapperMock,
                                                 mock.DALMapperMockFactory.DALContactTypeMapperMock,
                                                 mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                 mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            ApiContactTypeResponseModel response = await service.ByName(default(string));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.ByName(It.IsAny <string>()));
        }
コード例 #6
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IContactTypeRepository>();
            var model = new ApiContactTypeRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <ContactType>())).Returns(Task.FromResult(new ContactType()));
            var service = new ContactTypeService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLContactTypeMapperMock,
                                                 mock.DALMapperMockFactory.DALContactTypeMapperMock,
                                                 mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                 mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            CreateResponse <ApiContactTypeResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiContactTypeRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <ContactType>()));
        }
コード例 #7
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <IContactTypeRepository>();
            var records = new List <ContactType>();

            records.Add(new ContactType());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new ContactTypeService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLContactTypeMapperMock,
                                                 mock.DALMapperMockFactory.DALContactTypeMapperMock,
                                                 mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                 mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            List <ApiContactTypeResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
コード例 #8
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IContactTypeRepository>();
            var model = new ApiContactTypeRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new ContactTypeService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLContactTypeMapperMock,
                                                 mock.DALMapperMockFactory.DALContactTypeMapperMock,
                                                 mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                 mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.ContactTypeModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }
コード例 #9
0
 public bool ContactTypeInUse(ContactTypeBO a)
 {
     return(ContactTypeService.ContactTypeInUse(a.parseDomain()));
 }
コード例 #10
0
 public void GetContactTypes()
 {
     _contactTypes = ContactTypeService.GetAllContactTypes();
 }
コード例 #11
0
 public ContactTypesController()
 {
     _contactTypeService = new ContactTypeService();
 }