Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 public async Task CreateAsync(AppliedTag tag)
 {
     await _context.AddAsync(tag);
 }