public virtual ApiBucketClientRequestModel MapServerResponseToClientRequest(
            ApiBucketServerResponseModel response)
        {
            var request = new ApiBucketClientRequestModel();

            request.SetProperties(
                response.ExternalId,
                response.Name);
            return(request);
        }
Пример #2
0
        public virtual ApiBucketServerResponseModel MapEntityToModel(
            Bucket item)
        {
            var model = new ApiBucketServerResponseModel();

            model.SetProperties(item.Id,
                                item.ExternalId,
                                item.Name);

            return(model);
        }
        public virtual ApiBucketServerResponseModel MapServerRequestToResponse(
            int id,
            ApiBucketServerRequestModel request)
        {
            var response = new ApiBucketServerResponseModel();

            response.SetProperties(id,
                                   request.ExternalId,
                                   request.Name);
            return(response);
        }
Пример #4
0
        public void MapEntityToModel()
        {
            var    mapper = new DALBucketMapper();
            Bucket item   = new Bucket();

            item.SetProperties(1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A");
            ApiBucketServerResponseModel response = mapper.MapEntityToModel(item);

            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Пример #5
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);
        }
Пример #6
0
        public virtual async Task <UpdateResponse <ApiBucketServerResponseModel> > Update(
            int id,
            ApiBucketServerRequestModel model)
        {
            var validationResult = await this.BucketModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Bucket record = this.DalBucketMapper.MapModelToEntity(id, model);
                await this.BucketRepository.Update(record);

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

                ApiBucketServerResponseModel apiModel = this.DalBucketMapper.MapEntityToModel(record);
                await this.mediator.Publish(new BucketUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiBucketServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiBucketServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public void SetBucketIdNavigation(ApiBucketServerResponseModel value)
 {
     this.BucketIdNavigation = value;
 }
Пример #8
0
 public BucketUpdatedNotification(ApiBucketServerResponseModel record)
 {
     this.Record = record;
 }