示例#1
0
        public async Task <SwordDto> UpdateAsync(ISwordUpdate swordDto)
        {
            var sword = await _swordContext.Swords.FirstOrDefaultAsync(x => x.Id == swordDto.Id);

            if (sword == null)
            {
                return(await CreateAsync(swordDto as SwordDto));
            }

            sword = _mapper.Map(swordDto, sword);

            _swordContext.Update(sword);
            await _swordContext.SaveChangesAsync();

            return(swordDto as SwordDto);
        }
示例#2
0
        public async Task <BlackSmithDto> UpdateAsync(IBlackSmithUpdate blackSmithDto)
        {
            var blackSmith = await _swordContext.BlackSimths.FirstOrDefaultAsync(x => x.Id == blackSmithDto.Id);

            if (blackSmith == null)
            {
                return(await CreateAsync(blackSmithDto as BlackSmithDto));
            }

            blackSmith = _mapper.Map(blackSmithDto, blackSmith);

            _swordContext.Update(blackSmith);
            await _swordContext.SaveChangesAsync();

            blackSmithDto = _mapper.Map <BlackSmithDto>(blackSmith);

            return(blackSmithDto as BlackSmithDto);
        }