示例#1
0
        public JsonPatchDocument <ApiEventStatusServerRequestModel> CreatePatch(ApiEventStatusServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiEventStatusServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
示例#2
0
        public virtual ApiEventStatusServerRequestModel MapServerResponseToRequest(
            ApiEventStatusServerResponseModel response)
        {
            var request = new ApiEventStatusServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
示例#3
0
        public virtual ApiEventStatusServerResponseModel MapServerRequestToResponse(
            int id,
            ApiEventStatusServerRequestModel request)
        {
            var response = new ApiEventStatusServerResponseModel();

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

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

            response.Name.Should().Be("A");
        }
        public virtual EventStatus MapModelToEntity(
            int id,
            ApiEventStatusServerRequestModel model
            )
        {
            EventStatus item = new EventStatus();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
示例#6
0
        public virtual async Task <CreateResponse <ApiEventStatusServerResponseModel> > Create(
            ApiEventStatusServerRequestModel model)
        {
            CreateResponse <ApiEventStatusServerResponseModel> response = ValidationResponseFactory <ApiEventStatusServerResponseModel> .CreateResponse(await this.EventStatusModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                EventStatus record = this.DalEventStatusMapper.MapModelToEntity(default(int), model);
                record = await this.EventStatusRepository.Create(record);

                response.SetRecord(this.DalEventStatusMapper.MapEntityToModel(record));
                await this.mediator.Publish(new EventStatusCreatedNotification(response.Record));
            }

            return(response);
        }
示例#7
0
        public virtual async Task <UpdateResponse <ApiEventStatusServerResponseModel> > Update(
            int id,
            ApiEventStatusServerRequestModel model)
        {
            var validationResult = await this.EventStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                EventStatus record = this.DalEventStatusMapper.MapModelToEntity(id, model);
                await this.EventStatusRepository.Update(record);

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

                ApiEventStatusServerResponseModel apiModel = this.DalEventStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new EventStatusUpdatedNotification(apiModel));

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