Ejemplo 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);
        }
Ejemplo n.º 2
0
        public virtual ApiTeacherTeacherSkillClientRequestModel MapServerResponseToClientRequest(
            ApiTeacherTeacherSkillServerResponseModel response)
        {
            var request = new ApiTeacherTeacherSkillClientRequestModel();

            request.SetProperties(
                response.TeacherId,
                response.TeacherSkillId);
            return(request);
        }
Ejemplo n.º 3
0
        public virtual ApiTeacherTeacherSkillServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTeacherTeacherSkillServerRequestModel request)
        {
            var response = new ApiTeacherTeacherSkillServerResponseModel();

            response.SetProperties(id,
                                   request.TeacherId,
                                   request.TeacherSkillId);
            return(response);
        }
        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 <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));
            }
        }
 public TeacherTeacherSkillUpdatedNotification(ApiTeacherTeacherSkillServerResponseModel record)
 {
     this.Record = record;
 }