using Siger.Middlelayer.Repository.Paged;
using Siger.Middlelayer.IMSRepository.Entities;
using Siger.Middlelayer.IMSRepository.Repositories.Interface;
using Siger.Middlelayer.IMSRepository.Response;

namespace Siger.Middlelayer.IMSRepository.Repositories
{
    internal class ToolLifeToolMeatureRepository : IMSRepositoryBase<siger_project_ims_meature>, IToolLifeToolMeatureRepository
    {
        private readonly ApiIMSDbContext _context;
        public ToolLifeToolMeatureRepository(ApiIMSDbContext context) : base(context)
        {
            _context = context;
        }

        public IPagedCollectionResult<ResponseGetToolMeature> GetPagedList(int workorder_id, int technology_id, int page, int pagesize, int project_id)
        {
            return null;

            //var querylist = from q in _context.siger_project_ims_package
            //    join t in _context.siger_project_ims_tool on q.tool_id equals t.id
            //    where q.project_id == project_id &&
            //          q.confirm_status == ChoiceStatus.HasApply
            //    select new ResponseGetToolMeature
            //    {
            //        id = q.id,
            //        tool_number = t.name,
            //        tool_id = t.id,
            //        status = (int)q.measure_status,
            //        actual_diameter = q.actual_diameter.ToStr(),
            //        actual_length = q.actual_length.ToStr()
            //    };
            //var list = new List<ResponseGetToolMeature>();
            //foreach (var meature in querylist)
            //{
            //    var tooltech = _context.siger_project_ims_tech_tool.FirstOrDefault(q =>
            //        q.cutter_number == meature.cutter_number
            //        && q.tool_model == meature.tool_id
            //        && q.handle_model == meature.handler_id
            //        && q.technology_id == technology_id
            //        && q.project_id == project_id && q.status == (int) RowState.Valid);
            //    if (tooltech != null)
            //    {
            //        list.Add(new ResponseGetToolMeature
            //        {
            //            id = meature.id,
            //            cutter_number = meature.cutter_number,
            //            tool_number = meature.tool_number,
            //            handler_number = meature.handler_number,
            //            flute_length = tooltech.flute_length.ToStr(),
            //            flute_count = tooltech.flute_count.ToStr(),
            //            down_length = tooltech.down_length.ToStr(),
            //            reach_length = tooltech.reach_length.ToStr(),
            //            upper_tolerance = tooltech.upper_tolerance,
            //            down_tolerance = tooltech.down_tolerance,
            //            status = meature.status,
            //            actual_diameter = meature.actual_diameter.ToStr(),
            //            actual_length = meature.actual_length.ToStr()
            //        });
            //    }
            //}

            //var totalCount = list.Count;
            //var entities = list.Skip((page - 1) * pagesize).Take(pagesize).ToList();
            //return new PagedCollectionResult<ResponseGetToolMeature>(entities, totalCount);
        }
    }
}
