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);
        }
        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);
        }
        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));
            }
        }