Exemple #1
0
        public virtual ApiStudioClientRequestModel MapServerResponseToClientRequest(
            ApiStudioServerResponseModel response)
        {
            var request = new ApiStudioClientRequestModel();

            request.SetProperties(
                response.Address1,
                response.Address2,
                response.City,
                response.Name,
                response.Province,
                response.Website,
                response.Zip);
            return(request);
        }
Exemple #2
0
        public virtual ApiStudioServerResponseModel MapEntityToModel(
            Studio item)
        {
            var model = new ApiStudioServerResponseModel();

            model.SetProperties(item.Id,
                                item.Address1,
                                item.Address2,
                                item.City,
                                item.Name,
                                item.Province,
                                item.Website,
                                item.Zip);

            return(model);
        }
Exemple #3
0
        public virtual ApiStudioServerResponseModel MapServerRequestToResponse(
            int id,
            ApiStudioServerRequestModel request)
        {
            var response = new ApiStudioServerResponseModel();

            response.SetProperties(id,
                                   request.Address1,
                                   request.Address2,
                                   request.City,
                                   request.Name,
                                   request.Province,
                                   request.Website,
                                   request.Zip);
            return(response);
        }
Exemple #4
0
        public void MapEntityToModel()
        {
            var    mapper = new DALStudioMapper();
            Studio item   = new Studio();

            item.SetProperties(1, "A", "A", "A", "A", "A", "A", "A");
            ApiStudioServerResponseModel response = mapper.MapEntityToModel(item);

            response.Address1.Should().Be("A");
            response.Address2.Should().Be("A");
            response.City.Should().Be("A");
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.Province.Should().Be("A");
            response.Website.Should().Be("A");
            response.Zip.Should().Be("A");
        }
Exemple #5
0
        public virtual async Task <UpdateResponse <ApiStudioServerResponseModel> > Update(
            int id,
            ApiStudioServerRequestModel model)
        {
            var validationResult = await this.StudioModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Studio record = this.DalStudioMapper.MapModelToEntity(id, model);
                await this.StudioRepository.Update(record);

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

                ApiStudioServerResponseModel apiModel = this.DalStudioMapper.MapEntityToModel(record);
                await this.mediator.Publish(new StudioUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiStudioServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiStudioServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemple #6
0
 public StudioUpdatedNotification(ApiStudioServerResponseModel record)
 {
     this.Record = record;
 }