public void InsertAdvertisement(Advertisement advertisement) { if (advertisement == null) throw new ArgumentNullException("advertisement"); _advertisementRepository.Insert(advertisement); _eventPublisher.EntityInserted(advertisement); }
public void DeleteAdvertisement(Advertisement advertisement) { if (advertisement == null) throw new ArgumentNullException("advertisement"); var ad = _advertisementRepository.GetById(advertisement.Id); ad.Deleted = true; UpdateAdvertisement(ad); _eventPublisher.EntityDeleted(advertisement); }
protected virtual void PrepareStoresMappingModel(AdvertisementModel model, Advertisement advertisement, bool excludeProperties) { if (model == null) throw new ArgumentNullException("model"); model.AvailableStores = _storeService .GetAllStores() .Select(s => s.ToModel()) .ToList(); if (!excludeProperties) { if (advertisement != null) { //model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(advertisement); } } }
public void UpdateAdvertisement(Advertisement advertisement) { if (advertisement == null) throw new ArgumentNullException("advertisement"); _advertisementRepository.Update(advertisement); _eventPublisher.EntityUpdated(advertisement); }
protected virtual void PrepareAdvertisementModel(AdvertisementModel model, Advertisement advertisement, bool setPredefinedValues, bool excludeProperties) { if (model == null) throw new ArgumentNullException("model"); if (advertisement != null) { model.CreatedOn = _dateTimeHelper.ConvertToUserTime(advertisement.CreatedOnUtc, DateTimeKind.Utc); model.UpdatedOn = _dateTimeHelper.ConvertToUserTime(advertisement.UpdatedOnUtc, DateTimeKind.Utc); } //vendors model.IsLoggedInAsVendor = _workContext.CurrentVendor != null; model.AvailableVendors.Add(new SelectListItem { Text = "None", Value = "0" }); var vendors = _vendorService.GetAllVendors(showHidden: true); foreach (var vendor in vendors) { model.AvailableVendors.Add(new SelectListItem { Text = vendor.Name, Value = vendor.Id.ToString() }); } //default values if (setPredefinedValues) { model.Published = true; } }