using Edu.Model.ViewModel.Web;
using Edu.Repository.Web;
using System.Collections.Generic;
using VT.FW.DB;
using System.Linq;
using Edu.Common.Enum;

namespace Edu.Module.Web
{
    /// <summary>
    /// 咨询管理处理类
    /// </summary>
    public class WebAdvisoryModule
    {
        /// <summary>
        /// 咨询管理仓储层对象
        /// </summary>
        private readonly RB_Web_AdvisoryRepository web_AdvisoryRepository = new RB_Web_AdvisoryRepository();

        /// <summary>
        /// 获取咨询管理分页列表
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页显示调试</param>
        /// <param name="rowsCount">总条数</param>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public List<RB_Web_Advisory_ViewModel> GetWebAdvisoryPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Web_Advisory_ViewModel query)
        {
            return web_AdvisoryRepository.GetWebAdvisoryPageRepository(pageIndex, pageSize, out rowsCount, query);
        }

        /// <summary>
        /// 新增修改咨询管理
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SetWebAdvisoryModule(RB_Web_Advisory_ViewModel model)
        {
            bool flag;
            var newId = web_AdvisoryRepository.Insert(model);
            model.Id = newId;
            flag = newId > 0;
            return flag;
        }

        /// <summary>
        /// 修改咨询回复
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateWebAdvisoryModule(RB_Web_Advisory_ViewModel model)
        {
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_Web_Advisory_ViewModel.DealStatus),model.DealStatus },
                {nameof(RB_Web_Advisory_ViewModel.DealContent),model.DealContent },
                {nameof(RB_Web_Advisory_ViewModel.DealBy),model.DealBy },
                {nameof(RB_Web_Advisory_ViewModel.DealTime),model.DealTime },
            };
            var flag = web_AdvisoryRepository.Update(fileds, new WhereHelper(nameof(RB_Web_Advisory_ViewModel.Id), model.Id));
            return flag;
        }

        /// <summary>
        /// 根据编号获取咨询管理详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public RB_Web_Advisory_ViewModel GetWebAdvisoryModule(int Id)
        {
            var query = new RB_Web_Advisory_ViewModel()
            {
                Id = Id,
            };
            return web_AdvisoryRepository.GetWebAdvisoryEntityRepository(query);
        }

        /// <summary>
        /// 修改咨询管理状态
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Status">0-正常,1-删除</param>
        /// <returns></returns>
        public bool RemoveWebAdvisoryStatusModule(int Id, int Status)
        {
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_Web_Advisory_ViewModel.Status),Status },
            };
            var flag = web_AdvisoryRepository.Update(fileds, new WhereHelper(nameof(RB_Web_Advisory_ViewModel.Id), Id));
            return flag;
        }
    }
}
