Beispiel #1
0
        /// <summary>
        /// 根据用户名称获取相关的委托
        /// </summary>
        /// <param name="UserName">用户名称</param>
        /// <param name="moduleName">模块名称</param>
        /// <returns></returns>
        public static List <AgentSetEntity> GetAgentSetByUserName(string UserName, string moduleName = "")
        {
            //根据用户名获取 当前时间有效的委托
            var list = AgentSetDA.GetAgentSetByUserName(UserName);

            if (!string.IsNullOrEmpty(moduleName) && list != null && list.Count > 0)
            {
                list = list.Where(x => x.B_AGENTCONTENT.Split(';').Contains(moduleName)).ToList();
            }

            List <AgentSetEntity> nlist = new List <AgentSetEntity>();

            if (list != null && list.Count > 0)
            {
                foreach (var item in list)
                {
                    AgentSetEntity model = new AgentSetEntity();
                    model.b_DelegateName = item.B_DELEGATENAME;
                    model.b_AgentName    = item.B_AGENTNAME;
                    string startDate = !string.IsNullOrEmpty(item.B_STARTDATEMINUTE) ? item.B_STARTDATE + " " + item.B_STARTDATEMINUTE : item.B_STARTDATE;
                    string endDate   = !string.IsNullOrEmpty(item.B_ENDDATEMINUTE) ? item.B_ENDDATE + " " + item.B_ENDDATEMINUTE : item.B_ENDDATE;
                    model.b_StartDate    = DateTime.Parse(startDate);
                    model.b_EndDate      = DateTime.Parse(endDate);
                    model.b_AgentContent = item.B_AGENTCONTENT;
                    nlist.Add(model);
                }

                nlist = nlist.Where(x => x.b_StartDate <= DateTime.Now && x.b_EndDate >= DateTime.Now).ToList();
            }
            return(nlist);
        }
        /// <summary>
        /// 删除数据根据Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult DeleteAgentSetById(string id)
        {
            var retModel = new JsonReturnModel();

            try
            {
                var result = AgentSetDA.DeleteAgentSetById(inn, id);
                if (result.isError())
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }