예제 #1
0
        public virtual ApiVideoClientRequestModel MapServerResponseToClientRequest(
            ApiVideoServerResponseModel response)
        {
            var request = new ApiVideoClientRequestModel();

            request.SetProperties(
                response.Description,
                response.Title,
                response.Url);
            return(request);
        }
예제 #2
0
        public virtual ApiVideoServerResponseModel MapServerRequestToResponse(
            int id,
            ApiVideoServerRequestModel request)
        {
            var response = new ApiVideoServerResponseModel();

            response.SetProperties(id,
                                   request.Description,
                                   request.Title,
                                   request.Url);
            return(response);
        }
예제 #3
0
        public virtual ApiVideoServerResponseModel MapEntityToModel(
            Video item)
        {
            var model = new ApiVideoServerResponseModel();

            model.SetProperties(item.Id,
                                item.Description,
                                item.Title,
                                item.Url);

            return(model);
        }
예제 #4
0
        public void MapEntityToModel()
        {
            var   mapper = new DALVideoMapper();
            Video item   = new Video();

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

            response.Description.Should().Be("A");
            response.Id.Should().Be(1);
            response.Title.Should().Be("A");
            response.Url.Should().Be("A");
        }
예제 #5
0
        public virtual async Task <UpdateResponse <ApiVideoServerResponseModel> > Update(
            int id,
            ApiVideoServerRequestModel model)
        {
            var validationResult = await this.VideoModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Video record = this.DalVideoMapper.MapModelToEntity(id, model);
                await this.VideoRepository.Update(record);

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

                ApiVideoServerResponseModel apiModel = this.DalVideoMapper.MapEntityToModel(record);
                await this.mediator.Publish(new VideoUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiVideoServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiVideoServerResponseModel> .UpdateResponse(validationResult));
            }
        }
예제 #6
0
 public VideoUpdatedNotification(ApiVideoServerResponseModel record)
 {
     this.Record = record;
 }