Esempio n. 1
0
        public virtual ApiBankAccountServerResponseModel MapEntityToModel(
            BankAccount item)
        {
            var model = new ApiBankAccountServerResponseModel();

            model.SetProperties(item.Id,
                                item.AccountNumber,
                                item.ArtistId,
                                item.RoutingNumber);
            if (item.ArtistIdNavigation != null)
            {
                var artistIdModel = new ApiArtistServerResponseModel();
                artistIdModel.SetProperties(
                    item.ArtistIdNavigation.Id,
                    item.ArtistIdNavigation.AspNetUserId,
                    item.ArtistIdNavigation.Bio,
                    item.ArtistIdNavigation.ExternalId,
                    item.ArtistIdNavigation.Facebook,
                    item.ArtistIdNavigation.Name,
                    item.ArtistIdNavigation.SoundCloud,
                    item.ArtistIdNavigation.Twitter,
                    item.ArtistIdNavigation.Venmo,
                    item.ArtistIdNavigation.Website);

                model.SetArtistIdNavigation(artistIdModel);
            }

            return(model);
        }
Esempio n. 2
0
        public virtual ApiBankAccountClientRequestModel MapServerResponseToClientRequest(
            ApiBankAccountServerResponseModel response)
        {
            var request = new ApiBankAccountClientRequestModel();

            request.SetProperties(
                response.AccountNumber,
                response.ArtistId,
                response.RoutingNumber);
            return(request);
        }
Esempio n. 3
0
        public virtual ApiBankAccountServerResponseModel MapServerRequestToResponse(
            int id,
            ApiBankAccountServerRequestModel request)
        {
            var response = new ApiBankAccountServerResponseModel();

            response.SetProperties(id,
                                   request.AccountNumber,
                                   request.ArtistId,
                                   request.RoutingNumber);
            return(response);
        }
        public void MapEntityToModel()
        {
            var         mapper = new DALBankAccountMapper();
            BankAccount item   = new BankAccount();

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

            response.AccountNumber.Should().Be("A");
            response.ArtistId.Should().Be(1);
            response.Id.Should().Be(1);
            response.RoutingNumber.Should().Be("A");
        }
Esempio n. 5
0
        public virtual async Task <UpdateResponse <ApiBankAccountServerResponseModel> > Update(
            int id,
            ApiBankAccountServerRequestModel model)
        {
            var validationResult = await this.BankAccountModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                BankAccount record = this.DalBankAccountMapper.MapModelToEntity(id, model);
                await this.BankAccountRepository.Update(record);

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

                ApiBankAccountServerResponseModel apiModel = this.DalBankAccountMapper.MapEntityToModel(record);
                await this.mediator.Publish(new BankAccountUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiBankAccountServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiBankAccountServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public BankAccountUpdatedNotification(ApiBankAccountServerResponseModel record)
 {
     this.Record = record;
 }