public virtual ApiFileClientRequestModel MapServerResponseToClientRequest(
            ApiFileServerResponseModel response)
        {
            var request = new ApiFileClientRequestModel();

            request.SetProperties(
                response.BucketId,
                response.DateCreated,
                response.Description,
                response.Expiration,
                response.Extension,
                response.ExternalId,
                response.FileSizeInByte,
                response.FileTypeId,
                response.Location,
                response.PrivateKey,
                response.PublicKey);
            return(request);
        }
        public virtual ApiFileServerResponseModel MapServerRequestToResponse(
            int id,
            ApiFileServerRequestModel request)
        {
            var response = new ApiFileServerResponseModel();

            response.SetProperties(id,
                                   request.BucketId,
                                   request.DateCreated,
                                   request.Description,
                                   request.Expiration,
                                   request.Extension,
                                   request.ExternalId,
                                   request.FileSizeInByte,
                                   request.FileTypeId,
                                   request.Location,
                                   request.PrivateKey,
                                   request.PublicKey);
            return(response);
        }
Пример #3
0
        public void MapEntityToModel()
        {
            var  mapper = new DALFileMapper();
            File item   = new File();

            item.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1m, 1, "A", "A", "A");
            ApiFileServerResponseModel response = mapper.MapEntityToModel(item);

            response.BucketId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Description.Should().Be("A");
            response.Expiration.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Extension.Should().Be("A");
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.FileSizeInByte.Should().Be(1m);
            response.FileTypeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Location.Should().Be("A");
            response.PrivateKey.Should().Be("A");
            response.PublicKey.Should().Be("A");
        }
Пример #4
0
        public virtual ApiFileServerResponseModel MapEntityToModel(
            File item)
        {
            var model = new ApiFileServerResponseModel();

            model.SetProperties(item.Id,
                                item.BucketId,
                                item.DateCreated,
                                item.Description,
                                item.Expiration,
                                item.Extension,
                                item.ExternalId,
                                item.FileSizeInByte,
                                item.FileTypeId,
                                item.Location,
                                item.PrivateKey,
                                item.PublicKey);
            if (item.BucketIdNavigation != null)
            {
                var bucketIdModel = new ApiBucketServerResponseModel();
                bucketIdModel.SetProperties(
                    item.BucketIdNavigation.Id,
                    item.BucketIdNavigation.ExternalId,
                    item.BucketIdNavigation.Name);

                model.SetBucketIdNavigation(bucketIdModel);
            }

            if (item.FileTypeIdNavigation != null)
            {
                var fileTypeIdModel = new ApiFileTypeServerResponseModel();
                fileTypeIdModel.SetProperties(
                    item.FileTypeIdNavigation.Id,
                    item.FileTypeIdNavigation.Name);

                model.SetFileTypeIdNavigation(fileTypeIdModel);
            }

            return(model);
        }
Пример #5
0
        public virtual async Task <UpdateResponse <ApiFileServerResponseModel> > Update(
            int id,
            ApiFileServerRequestModel model)
        {
            var validationResult = await this.FileModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                File record = this.DalFileMapper.MapModelToEntity(id, model);
                await this.FileRepository.Update(record);

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

                ApiFileServerResponseModel apiModel = this.DalFileMapper.MapEntityToModel(record);
                await this.mediator.Publish(new FileUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiFileServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiFileServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #6
0
 public FileUpdatedNotification(ApiFileServerResponseModel record)
 {
     this.Record = record;
 }