/// <summary> /// Updates an existing AppliedTag. /// </summary> /// <param name="key">The AppliedTag's key.</param> /// <param name="appliedtag">The AppliedTag with updated informations.</param> public AppliedTag Put(long key, AppliedTag appliedtag) { appliedtag.Key = key; m_service.SaveAppliedTag(appliedtag); return(appliedtag); }
public void Save_EntityDoesNotExists_Exception() { var appliedTag = new AppliedTag(); appliedTag.EntityName = "Game"; appliedTag.EntityKey = 0; var target = new AppliedTagService(); ExceptionAssert.IsThrowing(new SpecificationNotSatisfiedException("There is no Entity 'Game' with key '0'."), () => { target.SaveAppliedTag(appliedTag); }); }
public void SaveAppliedTag_AppliedTagDoesNotExists_Created() { Stubs.GameRepository.Add(new Game(1)); Stubs.UnitOfWork.Commit(); var appliedtag = new AppliedTag(); appliedtag.EntityName = "Game"; appliedtag.EntityKey = 1; m_target.SaveAppliedTag(appliedtag); Assert.AreEqual(5, m_target.CountAllAppliedTags()); Assert.AreEqual(5, m_target.GetAppliedTagByKey(appliedtag.Key).Key); }
/// <inheritdoc /> public async Task <TagDto> AddTagAsync(long id, TagEdit tag) { var tagEntity = await _tagRepository.GetByName(tag.Name); if (tagEntity == null) { tagEntity = _mapper.Map <Tag>(tag); await _tagRepository.CreateAsync(tagEntity); } var appliedTagEntity = new AppliedTag() { RecipeId = id, Tag = tagEntity }; await _appliedTagRepository.CreateAsync(appliedTagEntity); await _repo.SaveAsync(); var dto = _mapper.Map <TagDto>(appliedTagEntity); return(dto); }
/// <summary> /// Creates a new AppliedTag. /// </summary> /// <param name="appliedtag">The AppliedTag to create.</param> /// <returns>The created AppliedTag with the key.</returns> public AppliedTag Post(AppliedTag appliedtag) { m_service.SaveAppliedTag(appliedtag); return(appliedtag); }
/// <inheritdoc /> public async Task CreateAsync(AppliedTag tag) { await _context.AddAsync(tag); }