public async Task <ValidationResult> ValidateUpdateAsync(int id, ApiArtistServerRequestModel model) { this.AspNetUserIdRules(); this.BioRules(); this.ExternalIdRules(); this.FacebookRules(); this.NameRules(); this.SoundCloudRules(); this.TwitterRules(); this.VenmoRules(); this.WebsiteRules(); return(await this.ValidateAsync(model, id)); }
public JsonPatchDocument <ApiArtistServerRequestModel> CreatePatch(ApiArtistServerRequestModel model) { var patch = new JsonPatchDocument <ApiArtistServerRequestModel>(); patch.Replace(x => x.AspNetUserId, model.AspNetUserId); patch.Replace(x => x.Bio, model.Bio); patch.Replace(x => x.ExternalId, model.ExternalId); patch.Replace(x => x.Facebook, model.Facebook); patch.Replace(x => x.Name, model.Name); patch.Replace(x => x.SoundCloud, model.SoundCloud); patch.Replace(x => x.Twitter, model.Twitter); patch.Replace(x => x.Venmo, model.Venmo); patch.Replace(x => x.Website, model.Website); return(patch); }
public virtual async Task <CreateResponse <ApiArtistServerResponseModel> > Create( ApiArtistServerRequestModel model) { CreateResponse <ApiArtistServerResponseModel> response = ValidationResponseFactory <ApiArtistServerResponseModel> .CreateResponse(await this.ArtistModelValidator.ValidateCreateAsync(model)); if (response.Success) { Artist record = this.DalArtistMapper.MapModelToEntity(default(int), model); record = await this.ArtistRepository.Create(record); response.SetRecord(this.DalArtistMapper.MapEntityToModel(record)); await this.mediator.Publish(new ArtistCreatedNotification(response.Record)); } return(response); }
public virtual ApiArtistServerRequestModel MapServerResponseToRequest( ApiArtistServerResponseModel response) { var request = new ApiArtistServerRequestModel(); request.SetProperties( response.AspNetUserId, response.Bio, response.ExternalId, response.Facebook, response.Name, response.SoundCloud, response.Twitter, response.Venmo, response.Website); return(request); }
public void MapModelToEntity() { var mapper = new DALArtistMapper(); ApiArtistServerRequestModel model = new ApiArtistServerRequestModel(); model.SetProperties("A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A", "A", "A", "A", "A"); Artist response = mapper.MapModelToEntity(1, model); response.AspNetUserId.Should().Be("A"); response.Bio.Should().Be("A"); response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.Facebook.Should().Be("A"); response.Name.Should().Be("A"); response.SoundCloud.Should().Be("A"); response.Twitter.Should().Be("A"); response.Venmo.Should().Be("A"); response.Website.Should().Be("A"); }
public virtual Artist MapModelToEntity( int id, ApiArtistServerRequestModel model ) { Artist item = new Artist(); item.SetProperties( id, model.AspNetUserId, model.Bio, model.ExternalId, model.Facebook, model.Name, model.SoundCloud, model.Twitter, model.Venmo, model.Website); return(item); }
public virtual async Task <UpdateResponse <ApiArtistServerResponseModel> > Update( int id, ApiArtistServerRequestModel model) { var validationResult = await this.ArtistModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Artist record = this.DalArtistMapper.MapModelToEntity(id, model); await this.ArtistRepository.Update(record); record = await this.ArtistRepository.Get(id); ApiArtistServerResponseModel apiModel = this.DalArtistMapper.MapEntityToModel(record); await this.mediator.Publish(new ArtistUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiArtistServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiArtistServerResponseModel> .UpdateResponse(validationResult)); } }