using MWS.Data.InterFace;
using MWS.Data.Manager;
using MWS.Domain.Dto;
using MWS.Library.Common;
using MWS.Library.Common.Module;
using MWS.Model;
using MWS.Model.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace MWS.Domain.Web.Controller
{
    public class WeightController:ApiController
    {
        [HttpGet]
        public PageResult<List<RecordDto>> GetRecords(int entranceId=1, int deviceId=1, int teamId=1, int pageIndex=1, int pageSize=10, DateTime? beginTime=null, DateTime? endTime=null)
        {
            PageResult<List<RecordDto>> result = new PageResult<List<RecordDto>>() { 
                PageIndex=pageIndex,
                PageSize=pageSize
            };

            IWeight  weightManage = new WeightManager();
            try
            {
                IZigbee zigbeeManager = new ZigbeeManager();
                PageData<RecordDto> pa = weightManage.GetAllRecords(entranceId,deviceId,teamId,beginTime,endTime,pageIndex,pageSize);

                result.Data = pa.Data.ToList();
                result.Message = "成功！";
            }
            catch (Exception ex)
            {
                result.Data = null;
                result.Message = "失败！";
            }

            return result;
        }
        
    }
}
