protected virtual ObservableChangeTracker GetChangeTracker(IRepository repository) { var retVal = new ObservableChangeTracker { RemoveAction = x => repository.Remove(x), AddAction = x => repository.Add(x) }; return retVal; }
public async Task RemovePlaylistAsync(long playlistId) { _playlistRepository.Remove(playlistId); await _dbContext.SaveChangesAsync(); }
public void Delete(string id) { _blogRepository.Remove(id); }
public void Delete(int id) { _ownerRepository.Remove(id); }
public bool Remove(T entity) { return(_repository.Remove(entity)); }
public void RemoveClient(Entities.Client dbClient) { _clients.Remove(dbClient.Id); }
public void Delete(int id) { _feedbackRepository.Remove(id); }
public async Task Delete(PlayerEntity player) { await _playerRepository.Remove(player); }
public void Remove(Link link) { _linkRepository.Remove(entity: link); }
public void Remove(EntityType entity) { _repository.Remove(entity); _repository.Save(); }
public async Task Delete(EmailEntity entity) { await _emailRepository.Remove(entity); await _bus.RaiseEvent(new EntityDeletedEvent <EmailEntity>(entity)).ConfigureAwait(false); }
public async Task Delete(int id) { await _skillRepository.Remove(id); }
public void Remove(CategoryModel model) { var Dmodel = _mapper.Map <Category>(model); _categoryRepository.Remove(Dmodel); }
public void Delete(int id) { _webMasterTypeRepository.Remove(id); }
public void Delete(int id, out bool result, out string message) { _blogRepository.Remove(id, out result, out message); }
public async Task RemoveAsync(Referee referee) { repository.Remove(referee); await repository.SaveAsync(); }
public virtual T Remove <T>(T entity) where T : class { return(Repository.Remove(entity)); }
public void Delete(int id) { _productRepository.Remove(id); }
public void RemoveItem(Member entity) { _eventrepo.Remove(entity); }
public void Remove(TEntity entity) { _repository.Remove(entity); _unitOfWork.Commit(); }
public virtual T Remove(T item) => _BaseRepo.Remove(item);
public void RemoveItem(Contact entity) { _contactrepo.Remove(entity); }
public void RemoveApiResource(Entities.ApiResource dbReource) { _apiResources.Remove(dbReource.Id); }
public virtual void Remove(int id) { _repository.Remove(id); }
public bool Remove(int id) { bool retorno = _repositorieDAL.Remove(id); return(retorno); }
public User Remove(User user) { return(_ur.Remove(user)); }
public virtual bool Remove(T entity) { _repository.Remove(entity); return(true); }
public void Delete(Category category) { _categoryRepository.Remove(category); _categoryRepository.SaveChange(); }
public async Task RemoveArtistAsync(long artistId) { _artistRepository.Remove(artistId); await _dbContext.SaveChangesAsync(); }
public virtual void DeletePost(TKey key) { Repository.Remove(key); Repository.SaveChanges(); }
private ObservableChangeTracker GetChangeTracker(IRepository repository, CustomerOrderEntity customerOrderEntity) { var retVal = new ObservableChangeTracker { RemoveAction = (x) => { repository.Remove(x); }, AddAction = (x) => { var address = x as AddressEntity; var shipment = x as ShipmentEntity; var lineItem = x as LineItemEntity; if (address != null) { address.CustomerOrder = customerOrderEntity; } if (shipment != null) { foreach (var shipmentItem in shipment.Items) { var orderLineItem = customerOrderEntity.Items.FirstOrDefault(item => item.Id == shipmentItem.Id); if (orderLineItem != null) { orderLineItem.Shipment = shipment; } else { shipmentItem.CustomerOrder = customerOrderEntity; } } shipment.Items = new NullCollection<LineItemEntity>(); } if (lineItem != null) { lineItem.CustomerOrder = customerOrderEntity; lineItem.CustomerOrderId = customerOrderEntity.Id; } repository.Add(x); } }; return retVal; }
public void Remove(TAggregateRoot entity) { _repository.Remove(entity); }
public override string Import(string catalogId, string propertySetId, ImportItem[] systemValues, ImportItem[] customValues, IRepository repository) { var _error = string.Empty; _repository = (ICatalogRepository)repository; var action = GetAction(systemValues.First(x => x.Name == "Action").Value); switch (action) { case ImportAction.Insert: var group = systemValues.First(y => y.Name == "GroupName").Value; var target = systemValues.First(y => y.Name == "TargetId").Value; var source = systemValues.First(y => y.Name == "ItemId").Value; var sourceItems = _repository.Items.Where(x => x.ItemId == source || x.Code == source).ToList(); Item sourceItem; //aa: below condition checks if more than 1 item found - catalogId should be provided and item of the catalog selected, otherwise return error if (sourceItems.Count() > 1) { var sourceCatName = systemValues.First(y => y.Name == "SourceCatalogId").Value; if (!string.IsNullOrEmpty(sourceCatName)) catalogId = _repository.Catalogs.Where(cat => cat.Name == sourceCatName).First().CatalogId; if (!string.IsNullOrEmpty(catalogId)) sourceItem = sourceItems.FirstOrDefault(x => x.CatalogId == catalogId); else { var catNames = string.Empty; sourceItems.ForEach(x => catNames = catNames + x.CatalogId + ", "); _error = string.Format(notUniqueSourceError, source, catNames); return _error; } } //aa: if 1 item found set it to sourceItem and go further else { sourceItem = sourceItems.FirstOrDefault(); } var targetItems = _repository.Items.Where(x => x.ItemId == target || x.Code == target).ToList(); Item targetItem; //aa: below condition checks if more than 1 item found - catalogId should be provided and item of the catalog selected, otherwise return error if (targetItems.Count() > 1) { var targetCatName = systemValues.First(y => y.Name == "TargetCatalogId").Value; if (!string.IsNullOrEmpty(targetCatName)) catalogId = _repository.Catalogs.Where(cat => cat.Name == targetCatName).First().CatalogId; if (!string.IsNullOrEmpty(catalogId)) targetItem = targetItems.FirstOrDefault(x => x.CatalogId == catalogId); else { var catNames = string.Empty; targetItems.ForEach(x => catNames = catNames + x.CatalogId + ", "); _error = string.Format(notUniqueTargetError, target, catNames); return _error; } } //aa: if 1 item found set it to sourceItem and go further else { targetItem = targetItems.FirstOrDefault(); } if (!string.IsNullOrEmpty(group) && targetItem != null && sourceItem != null) { var associationGroup = _repository.Associations.Where(x => x.AssociationGroup.Name == group && x.ItemId == targetItem.ItemId).SingleOrDefault(); string groupId; if (associationGroup == null) { var addGroup = new AssociationGroup() { ItemId = targetItem.ItemId, Name = group }; _repository.Add(addGroup); groupId = addGroup.AssociationGroupId; } else { groupId = associationGroup.AssociationGroupId; } var addItem = InitializeItem(null, systemValues); ((Association)addItem).AssociationGroupId = groupId; ((Association)addItem).ItemId = sourceItem.ItemId; _repository.Add(addItem); } else { _error = "Not all required data provided"; } break; case ImportAction.InsertAndReplace: var itemR = systemValues.FirstOrDefault(y => y.Name == "AssociationId"); if (itemR != null) { var originalItem = _repository.Associations.Where(x => x.ItemId == itemR.Value).SingleOrDefault(); if (originalItem != null) repository.Remove(originalItem); } var replaceItem = InitializeItem(null, systemValues); repository.Add(replaceItem); break; case ImportAction.Update: var itemU = systemValues.FirstOrDefault(y => y.Name == "AssociationId"); if (itemU != null) { var origItem = _repository.Associations.Where(x => x.ItemId == itemU.Value).SingleOrDefault(); if (origItem != null) { InitializeItem(origItem, systemValues); _repository.Update(origItem); } } break; case ImportAction.Delete: var itemD = systemValues.FirstOrDefault(y => y.Name == "AssociationId"); if (itemD != null) { var deleteItem = _repository.Associations.Where(x => x.ItemId == itemD.Value).SingleOrDefault(); if (deleteItem != null) _repository.Remove(deleteItem); } break; } return _error; }
// TODO: let's do content negotiation ourselves unless there is a nice // way to do it in Nancy like there seems to be for most things public CountryModule(IRepository<Domain.Country> countryRepository, CountryFactory countryFactory) : base("/countries") { Get["/"] = parameters => { var countryResources = countryRepository.FindAll() .Select(c => new Country {id = c.Id.ToString(), Name = c.Name}); var resource = countryResources.ToArray(); return Response.AsJson(resource); }; Get["/{id}"] = parameters => { var country = countryRepository.GetById((int)parameters.id); if (country == null) return HttpStatusCode.NotFound; var resource = new Country {id = country.Id.ToString(), Name = country.Name}; return Response.AsJson(resource); }; Post["/"] = parameters => { var countryResource = this.Bind<Country>(blacklistedProperties:"id"); var validationResult = this.Validate(countryResource); if (! validationResult.IsValid) { var response = Response.AsJson(validationResult.Errors); response.StatusCode = HttpStatusCode.BadRequest; return response; } var country = countryFactory.CreateCountry(countryResource.Name); countryRepository.Add(country); return Response.AsRedirect("/countries/"+country.Id); }; Put["/{id}"] = parameters => { var country = countryRepository.GetById((int) parameters.id); if (country == null) return HttpStatusCode.NotFound; // this correct for a put? should probably be some error // we don't actually support updates to countries! //country.Name = parameters.Name; return Response.AsRedirect("/countries/" + country.Id); }; Delete["/{id}"] = parameters => { var country = countryRepository.GetById((int)parameters.id); if (country == null) return HttpStatusCode.NotFound; // this correct for a put? should probably be some error countryRepository.Remove(country); return HttpStatusCode.OK; }; }