示例#1
0
        public AutoBook Get(string id)
        {
            var autoBookId = AutoBookProfile.AutoBookCollectionIdToEntityAutoBookId(id);

            return(_dbContext.Query <Entities.Tenant.AutoBookApi.AutoBook>()
                   .Where(x => x.AutoBookId == autoBookId).ProjectTo <AutoBook>(_mapper.ConfigurationProvider).FirstOrDefault());
        }
示例#2
0
        public void Delete(string id)
        {
            var autoBookId = AutoBookProfile.AutoBookCollectionIdToEntityAutoBookId(id);

            var entity = _dbContext.Query <Entities.Tenant.AutoBookApi.AutoBook>()
                         .Include(x => x.Task)
                         .FirstOrDefault(x => x.AutoBookId == autoBookId);

            if (entity != null)
            {
                _dbContext.Remove(entity);
            }
        }
示例#3
0
        public void Update(AutoBook autoBook)
        {
            var autoBookId = AutoBookProfile.AutoBookCollectionIdToEntityAutoBookId(autoBook.Id);

            var entity = _dbContext.Query <Entities.Tenant.AutoBookApi.AutoBook>()
                         .Include(x => x.Task)
                         .FirstOrDefault(x => x.AutoBookId == autoBookId);

            if (entity != null)
            {
                _mapper.Map(autoBook, entity);
                _dbContext.Update(entity, post => post.MapTo(autoBook), _mapper);
            }
        }