public void Main() { // I need an ad for an image var imageAd = new ImageAdvertisement(); // Now I need an ad for text var textAd = new TextAdvertisement(); // Now I'm tightly coupled to these implementations }
public TextAdvertisementViewModel Create(TextAdvertisementViewModel model) { if (model != null && this.ModelState.IsValid) { var textAd = new TextAdvertisement() { Name = model.Name, Url = model.Url, Content = model.Content, AvailableClicks = model.AvailableClicks }; this.Data.TextAdvertisements.Add(textAd); this.Data.SaveChanges(); var mapped = Mapper.Map <TextAdvertisementViewModel>(textAd); mapped.Id = textAd.Id; return(mapped); } return(null); }