コード例 #1
0
ファイル: ServiceBase.cs プロジェクト: adwardliu/vc-community
		protected virtual ObservableChangeTracker GetChangeTracker(IRepository repository)
		{
			var retVal = new ObservableChangeTracker
			{
                RemoveAction = x => repository.Remove(x),
                AddAction = x => repository.Add(x)
			};

			return retVal;
		}
コード例 #2
0
 public async Task RemovePlaylistAsync(long playlistId)
 {
     _playlistRepository.Remove(playlistId);
     await _dbContext.SaveChangesAsync();
 }
コード例 #3
0
 public void Delete(string id)
 {
     _blogRepository.Remove(id);
 }
コード例 #4
0
 public void Delete(int id)
 {
     _ownerRepository.Remove(id);
 }
コード例 #5
0
 public bool Remove(T entity)
 {
     return(_repository.Remove(entity));
 }
コード例 #6
0
 public void RemoveClient(Entities.Client dbClient)
 {
     _clients.Remove(dbClient.Id);
 }
コード例 #7
0
 public void Delete(int id)
 {
     _feedbackRepository.Remove(id);
 }
コード例 #8
0
 public async Task Delete(PlayerEntity player)
 {
     await _playerRepository.Remove(player);
 }
コード例 #9
0
ファイル: LInkService.cs プロジェクト: NBakulin/DBShell
 public void Remove(Link link)
 {
     _linkRepository.Remove(entity: link);
 }
コード例 #10
0
 public void Remove(EntityType entity)
 {
     _repository.Remove(entity);
     _repository.Save();
 }
コード例 #11
0
ファイル: EmailDomainService.cs プロジェクト: csecong/emud
        public async Task Delete(EmailEntity entity)
        {
            await _emailRepository.Remove(entity);

            await _bus.RaiseEvent(new EntityDeletedEvent <EmailEntity>(entity)).ConfigureAwait(false);
        }
コード例 #12
0
 public async Task Delete(int id)
 {
     await _skillRepository.Remove(id);
 }
コード例 #13
0
        public void Remove(CategoryModel model)
        {
            var Dmodel = _mapper.Map <Category>(model);

            _categoryRepository.Remove(Dmodel);
        }
コード例 #14
0
 public void Delete(int id)
 {
     _webMasterTypeRepository.Remove(id);
 }
コード例 #15
0
 public void Delete(int id, out bool result, out string message)
 {
     _blogRepository.Remove(id, out result, out message);
 }
コード例 #16
0
 public async Task RemoveAsync(Referee referee)
 {
     repository.Remove(referee);
     await repository.SaveAsync();
 }
コード例 #17
0
ファイル: RepositoryAdapter.cs プロジェクト: yarutyunov/Yarn
 public virtual T Remove <T>(T entity) where T : class
 {
     return(Repository.Remove(entity));
 }
コード例 #18
0
 public void Delete(int id)
 {
     _productRepository.Remove(id);
 }
コード例 #19
0
 public void RemoveItem(Member entity)
 {
     _eventrepo.Remove(entity);
 }
コード例 #20
0
 public void Remove(TEntity entity)
 {
     _repository.Remove(entity);
     _unitOfWork.Commit();
 }
コード例 #21
0
 public virtual T Remove(T item) => _BaseRepo.Remove(item);
コード例 #22
0
ファイル: ContactService.cs プロジェクト: reloar/church
 public void RemoveItem(Contact entity)
 {
     _contactrepo.Remove(entity);
 }
コード例 #23
0
 public void RemoveApiResource(Entities.ApiResource dbReource)
 {
     _apiResources.Remove(dbReource.Id);
 }
コード例 #24
0
 public virtual void Remove(int id)
 {
     _repository.Remove(id);
 }
コード例 #25
0
        public bool Remove(int id)
        {
            bool retorno = _repositorieDAL.Remove(id);

            return(retorno);
        }
コード例 #26
0
ファイル: UserService.cs プロジェクト: asbamse/GamersUnited
 public User Remove(User user)
 {
     return(_ur.Remove(user));
 }
コード例 #27
0
 public virtual bool Remove(T entity)
 {
     _repository.Remove(entity);
     return(true);
 }
コード例 #28
0
 public void Delete(Category category)
 {
     _categoryRepository.Remove(category);
     _categoryRepository.SaveChange();
 }
コード例 #29
0
 public async Task RemoveArtistAsync(long artistId)
 {
     _artistRepository.Remove(artistId);
     await _dbContext.SaveChangesAsync();
 }
コード例 #30
0
 public virtual void DeletePost(TKey key)
 {
     Repository.Remove(key);
     Repository.SaveChanges();
 }
コード例 #31
0
		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;
		}
コード例 #32
0
 public void Remove(TAggregateRoot entity)
 {
     _repository.Remove(entity);
 }
コード例 #33
0
		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;
		}
コード例 #34
0
        // 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;
                };
        }