コード例 #1
0
        public JsonPatchDocument <ApiEventStudentServerRequestModel> CreatePatch(ApiEventStudentServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiEventStudentServerRequestModel>();

            patch.Replace(x => x.EventId, model.EventId);
            patch.Replace(x => x.StudentId, model.StudentId);
            return(patch);
        }
コード例 #2
0
        public virtual ApiEventStudentServerRequestModel MapServerResponseToRequest(
            ApiEventStudentServerResponseModel response)
        {
            var request = new ApiEventStudentServerRequestModel();

            request.SetProperties(
                response.EventId,
                response.StudentId);
            return(request);
        }
コード例 #3
0
        public void MapModelToEntity()
        {
            var mapper = new DALEventStudentMapper();
            ApiEventStudentServerRequestModel model = new ApiEventStudentServerRequestModel();

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

            response.EventId.Should().Be(1);
            response.StudentId.Should().Be(1);
        }
コード例 #4
0
        public virtual ApiEventStudentServerResponseModel MapServerRequestToResponse(
            int id,
            ApiEventStudentServerRequestModel request)
        {
            var response = new ApiEventStudentServerResponseModel();

            response.SetProperties(id,
                                   request.EventId,
                                   request.StudentId);
            return(response);
        }
コード例 #5
0
        public virtual EventStudent MapModelToEntity(
            int id,
            ApiEventStudentServerRequestModel model
            )
        {
            EventStudent item = new EventStudent();

            item.SetProperties(
                id,
                model.EventId,
                model.StudentId);
            return(item);
        }
コード例 #6
0
        public virtual async Task <CreateResponse <ApiEventStudentServerResponseModel> > Create(
            ApiEventStudentServerRequestModel model)
        {
            CreateResponse <ApiEventStudentServerResponseModel> response = ValidationResponseFactory <ApiEventStudentServerResponseModel> .CreateResponse(await this.EventStudentModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                EventStudent record = this.DalEventStudentMapper.MapModelToEntity(default(int), model);
                record = await this.EventStudentRepository.Create(record);

                response.SetRecord(this.DalEventStudentMapper.MapEntityToModel(record));
                await this.mediator.Publish(new EventStudentCreatedNotification(response.Record));
            }

            return(response);
        }
コード例 #7
0
        public virtual async Task <UpdateResponse <ApiEventStudentServerResponseModel> > Update(
            int id,
            ApiEventStudentServerRequestModel model)
        {
            var validationResult = await this.EventStudentModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                EventStudent record = this.DalEventStudentMapper.MapModelToEntity(id, model);
                await this.EventStudentRepository.Update(record);

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

                ApiEventStudentServerResponseModel apiModel = this.DalEventStudentMapper.MapEntityToModel(record);
                await this.mediator.Publish(new EventStudentUpdatedNotification(apiModel));

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