Пример #1
0
        public JsonPatchDocument <ApiTeacherSkillServerRequestModel> CreatePatch(ApiTeacherSkillServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiTeacherSkillServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
Пример #2
0
        public virtual ApiTeacherSkillServerRequestModel MapServerResponseToRequest(
            ApiTeacherSkillServerResponseModel response)
        {
            var request = new ApiTeacherSkillServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Пример #3
0
        public virtual ApiTeacherSkillServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTeacherSkillServerRequestModel request)
        {
            var response = new ApiTeacherSkillServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALTeacherSkillMapper();
            ApiTeacherSkillServerRequestModel model = new ApiTeacherSkillServerRequestModel();

            model.SetProperties("A");
            TeacherSkill response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
        }
Пример #5
0
        public virtual TeacherSkill MapModelToEntity(
            int id,
            ApiTeacherSkillServerRequestModel model
            )
        {
            TeacherSkill item = new TeacherSkill();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Пример #6
0
        public virtual async Task <CreateResponse <ApiTeacherSkillServerResponseModel> > Create(
            ApiTeacherSkillServerRequestModel model)
        {
            CreateResponse <ApiTeacherSkillServerResponseModel> response = ValidationResponseFactory <ApiTeacherSkillServerResponseModel> .CreateResponse(await this.TeacherSkillModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                TeacherSkill record = this.DalTeacherSkillMapper.MapModelToEntity(default(int), model);
                record = await this.TeacherSkillRepository.Create(record);

                response.SetRecord(this.DalTeacherSkillMapper.MapEntityToModel(record));
                await this.mediator.Publish(new TeacherSkillCreatedNotification(response.Record));
            }

            return(response);
        }
Пример #7
0
        public virtual async Task <UpdateResponse <ApiTeacherSkillServerResponseModel> > Update(
            int id,
            ApiTeacherSkillServerRequestModel model)
        {
            var validationResult = await this.TeacherSkillModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                TeacherSkill record = this.DalTeacherSkillMapper.MapModelToEntity(id, model);
                await this.TeacherSkillRepository.Update(record);

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

                ApiTeacherSkillServerResponseModel apiModel = this.DalTeacherSkillMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TeacherSkillUpdatedNotification(apiModel));

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