public JsonPatchDocument <ApiBucketServerRequestModel> CreatePatch(ApiBucketServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiBucketServerRequestModel>();

            patch.Replace(x => x.ExternalId, model.ExternalId);
            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
        public virtual ApiBucketServerRequestModel MapServerResponseToRequest(
            ApiBucketServerResponseModel response)
        {
            var request = new ApiBucketServerRequestModel();

            request.SetProperties(
                response.ExternalId,
                response.Name);
            return(request);
        }
        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 MapModelToEntity()
        {
            var mapper = new DALBucketMapper();
            ApiBucketServerRequestModel model = new ApiBucketServerRequestModel();

            model.SetProperties(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A");
            Bucket response = mapper.MapModelToEntity(1, model);

            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Name.Should().Be("A");
        }
예제 #5
0
        public virtual Bucket MapModelToEntity(
            int id,
            ApiBucketServerRequestModel model
            )
        {
            Bucket item = new Bucket();

            item.SetProperties(
                id,
                model.ExternalId,
                model.Name);
            return(item);
        }
예제 #6
0
        public virtual async Task <CreateResponse <ApiBucketServerResponseModel> > Create(
            ApiBucketServerRequestModel model)
        {
            CreateResponse <ApiBucketServerResponseModel> response = ValidationResponseFactory <ApiBucketServerResponseModel> .CreateResponse(await this.BucketModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                Bucket record = this.DalBucketMapper.MapModelToEntity(default(int), model);
                record = await this.BucketRepository.Create(record);

                response.SetRecord(this.DalBucketMapper.MapEntityToModel(record));
                await this.mediator.Publish(new BucketCreatedNotification(response.Record));
            }

            return(response);
        }
예제 #7
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));
            }
        }