Esempio n. 1
0
        public virtual ApiTeacherTeacherSkillServerResponseModel MapEntityToModel(
            TeacherTeacherSkill item)
        {
            var model = new ApiTeacherTeacherSkillServerResponseModel();

            model.SetProperties(item.Id,
                                item.TeacherId,
                                item.TeacherSkillId);
            if (item.TeacherIdNavigation != null)
            {
                var teacherIdModel = new ApiTeacherServerResponseModel();
                teacherIdModel.SetProperties(
                    item.TeacherIdNavigation.Id,
                    item.TeacherIdNavigation.Birthday,
                    item.TeacherIdNavigation.Email,
                    item.TeacherIdNavigation.FirstName,
                    item.TeacherIdNavigation.LastName,
                    item.TeacherIdNavigation.Phone,
                    item.TeacherIdNavigation.UserId);

                model.SetTeacherIdNavigation(teacherIdModel);
            }

            if (item.TeacherSkillIdNavigation != null)
            {
                var teacherSkillIdModel = new ApiTeacherSkillServerResponseModel();
                teacherSkillIdModel.SetProperties(
                    item.TeacherSkillIdNavigation.Id,
                    item.TeacherSkillIdNavigation.Name);

                model.SetTeacherSkillIdNavigation(teacherSkillIdModel);
            }

            return(model);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALTeacherTeacherSkillMapper();
            ApiTeacherTeacherSkillServerRequestModel model = new ApiTeacherTeacherSkillServerRequestModel();

            model.SetProperties(1, 1);
            TeacherTeacherSkill response = mapper.MapModelToEntity(1, model);

            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }
        public void MapEntityToModel()
        {
            var mapper = new DALTeacherTeacherSkillMapper();
            TeacherTeacherSkill item = new TeacherTeacherSkill();

            item.SetProperties(1, 1, 1);
            ApiTeacherTeacherSkillServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }
        public virtual async Task <ApiTeacherTeacherSkillServerResponseModel> Get(int id)
        {
            TeacherTeacherSkill record = await this.TeacherTeacherSkillRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalTeacherTeacherSkillMapper.MapEntityToModel(record));
            }
        }
        public void MapEntityToModelList()
        {
            var mapper = new DALTeacherTeacherSkillMapper();
            TeacherTeacherSkill item = new TeacherTeacherSkill();

            item.SetProperties(1, 1, 1);
            List <ApiTeacherTeacherSkillServerResponseModel> response = mapper.MapEntityToModel(new List <TeacherTeacherSkill>()
            {
                { item }
            });

            response.Count.Should().Be(1);
        }
Esempio n. 6
0
        public virtual TeacherTeacherSkill MapModelToEntity(
            int id,
            ApiTeacherTeacherSkillServerRequestModel model
            )
        {
            TeacherTeacherSkill item = new TeacherTeacherSkill();

            item.SetProperties(
                id,
                model.TeacherId,
                model.TeacherSkillId);
            return(item);
        }
        public virtual async Task <CreateResponse <ApiTeacherTeacherSkillServerResponseModel> > Create(
            ApiTeacherTeacherSkillServerRequestModel model)
        {
            CreateResponse <ApiTeacherTeacherSkillServerResponseModel> response = ValidationResponseFactory <ApiTeacherTeacherSkillServerResponseModel> .CreateResponse(await this.TeacherTeacherSkillModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                TeacherTeacherSkill record = this.DalTeacherTeacherSkillMapper.MapModelToEntity(default(int), model);
                record = await this.TeacherTeacherSkillRepository.Create(record);

                response.SetRecord(this.DalTeacherTeacherSkillMapper.MapEntityToModel(record));
                await this.mediator.Publish(new TeacherTeacherSkillCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 8
0
        public async void Get_ShouldReturnRecords()
        {
            var mock   = new ServiceMockFacade <ITeacherTeacherSkillService, ITeacherTeacherSkillRepository>();
            var record = new TeacherTeacherSkill();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new TeacherTeacherSkillService(mock.LoggerMock.Object,
                                                         mock.MediatorMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.TeacherTeacherSkillModelValidatorMock.Object,
                                                         mock.DALMapperMockFactory.DALTeacherTeacherSkillMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public virtual async Task <UpdateResponse <ApiTeacherTeacherSkillServerResponseModel> > Update(
            int id,
            ApiTeacherTeacherSkillServerRequestModel model)
        {
            var validationResult = await this.TeacherTeacherSkillModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                TeacherTeacherSkill record = this.DalTeacherTeacherSkillMapper.MapModelToEntity(id, model);
                await this.TeacherTeacherSkillRepository.Update(record);

                record = await this.TeacherTeacherSkillRepository.Get(id);

                ApiTeacherTeacherSkillServerResponseModel apiModel = this.DalTeacherTeacherSkillMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TeacherTeacherSkillUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTeacherTeacherSkillServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTeacherTeacherSkillServerResponseModel> .UpdateResponse(validationResult));
            }
        }