using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using AutoMapper;
|
using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.EntityFrameworkCore;
|
using zhengcaioa.Models;
|
|
namespace Services
|
{
|
public class DtChannelArticleNewsService: IDtChannelArticleNewsService
|
{
|
private readonly zcwebContext _context;
|
private readonly IMapper _mapper;
|
public DtChannelArticleNewsService(zcwebContext context, IMapper mapper)
|
{
|
_context = context;
|
_mapper = mapper;
|
}
|
|
|
public List<DtChannelArticleNewsDTO> GetList(DtChannelArticleNewsDTOSearch searchEntity)
|
{
|
|
var entity = (from a in _context.DtChannelArticleNews.Where(x => x.Status == 0)
|
join b in _context.DtArticleCategories on a.CategoryId equals b.Id
|
|
|
where a.Status == 0
|
&& (string.IsNullOrWhiteSpace(searchEntity.UserName) || a.UserName == searchEntity.UserName.Trim())
|
&& ( !searchEntity.AddTime.HasValue || a.AddTime >= searchEntity.AddTime.Value.Date )
|
&& (!searchEntity.EndTime.HasValue || a.AddTime < searchEntity.EndTime.Value.Date )
|
|
&& (searchEntity.CategoryId <= 0 || b.ParentId == searchEntity.CategoryId )
|
select a
|
).ToList();
|
|
|
var result = _mapper.Map<List<DtChannelArticleNewsDTO>>(entity);
|
|
|
return result;
|
}
|
}
|
}
|