示例#1
0
 public Erpusers(Erpuser erpuser)
 {
     //Id
     this.ErproleId = erpuser.ErproleId;
     //角色
     this.ErproleName = erpuser.ErproleName;
     //权限
     this.ERProlePower = erpuser.ERProlePower;
 }
示例#2
0
        public static Erpuser ValidateUser(Erpuser erpuser)
        {
            Erpuser user = null;

            using Repository <Erpuser> _repo = new Repository <Erpuser>();
            user = _repo.Erpuser
                   .Where(u => u.UserName.Equals(erpuser.UserName) &&
                          u.Password.Equals(erpuser.Password)
                          ).FirstOrDefault();



            return(user);
        }
示例#3
0
        /// <summary>
        /// 根据模型插入
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>是否成功</returns>
        public bool Insert(Erpuser model, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var insert = new LambdaInsert <Erpuser>();

            if (!model.ErproleName.IsNullOrEmpty())
            {
                insert.Insert(p => p.ErproleName == model.ErproleName);
            }
            if (!model.ERProlePower.IsNullOrEmpty())
            {
                insert.Insert(p => p.ERProlePower == model.ERProlePower);
            }
            return(insert.GetInsertResult(connection, transaction) >= 0);
        }
示例#4
0
        /// <summary>
        /// 根据模型更新
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>是否成功</returns>
        public bool Update(Erpuser model, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var update = new LambdaUpdate <Erpuser>();

            if (!model.ErproleId.IsNullOrEmpty())
            {
                update.Where(p => p.ErproleId == model.ErproleId);
            }
            if (!model.ErproleName.IsNullOrEmpty())
            {
                update.Set(p => p.ErproleName == model.ErproleName);
            }
            if (!model.ERProlePower.IsNullOrEmpty())
            {
                update.Set(p => p.ERProlePower == model.ERProlePower);
            }
            return(update.GetUpdateResult(connection, transaction));
        }
示例#5
0
        /// <summary>
        /// 根据模型删除数据
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>是否成功</returns>
        public bool DeleteModel(Erpuser model = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var delete = new LambdaDelete <Erpuser>();

            if (model != null)
            {
                if (!model.ErproleId.IsNullOrEmpty())
                {
                    delete.Where(p => p.ErproleId == model.ErproleId);
                }
                if (!model.ErproleName.IsNullOrEmpty())
                {
                    delete.Where(p => p.ErproleName == model.ErproleName);
                }
                if (!model.ERProlePower.IsNullOrEmpty())
                {
                    delete.Where(p => p.ERProlePower == model.ERProlePower);
                }
            }
            return(delete.GetDeleteResult(connection, transaction));
        }
示例#6
0
        /// <summary>
        /// 数据条数
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>对象列表</returns>
        public int SelectCount(Erpuser model = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var query = new LambdaQuery <Erpuser>();

            if (model != null)
            {
                if (!model.ErproleId.IsNullOrEmpty())
                {
                    query.Where(p => p.ErproleId == model.ErproleId);
                }
                if (!model.ErproleName.IsNullOrEmpty())
                {
                    query.Where(p => p.ErproleName == model.ErproleName);
                }
                if (!model.ERProlePower.IsNullOrEmpty())
                {
                    query.Where(p => p.ERProlePower == model.ERProlePower);
                }
            }
            return(query.GetQueryCount(connection, transaction));
        }
示例#7
0
        public async Task <IActionResult> ValidateUser([FromBody] Erpuser erpuser)
        {
            var result = await Task.Run(() =>
            {
                try
                {
                    //Response.Headers.Add("Access-Control-Allow-Origin", "*");
                    //Response.Headers.Add("Access-Control-Allow-Headers", "Accept");
                    //Response.Headers.Add("Access-Control-Request-Headers", "origin,x-requested-with");
                    //Response.Headers.Add("Access-Control-Allow-MethodsPOST, GET, OPTIONS, DELET", "Accept");
                    Erpuser user = UserManagmentHelper.ValidateUser(erpuser);

                    if (user != null)
                    {
                        var _branch = UserManagmentHelper.GetBranchesByUser(user.SeqId);
                        var shiftId = new UserManagmentHelper().GetShiftId(user.SeqId, _branch.FirstOrDefault());
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = user
                        }));
                    }

                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "User Name/ Password not valid."
                    }));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = ex.InnerException == null ? ex.Message : ex.InnerException.Message
                    }));
                }
            });

            return(result);
        }
示例#8
0
        /// <summary>
        /// 筛选全部数据
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>对象列表</returns>
        public List <Erpuser> SelectAll(Erpuser model = null, string SelectFiled = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var query = new LambdaQuery <Erpuser>();

            if (model != null)
            {
                if (!model.ErproleId.IsNullOrEmpty())
                {
                    query.Where(p => p.ErproleId == model.ErproleId);
                }
                if (!model.ErproleName.IsNullOrEmpty())
                {
                    query.Where(p => p.ErproleName == model.ErproleName);
                }
                if (!model.ERProlePower.IsNullOrEmpty())
                {
                    query.Where(p => p.ERProlePower == model.ERProlePower);
                }
            }
            if (SelectFiled != null)
            {
                SelectFiled = SelectFiled.ToLowerInvariant();
                if (SelectFiled.Contains("erproleid,"))
                {
                    query.Select(p => new { p.ErproleId });
                }
                if (SelectFiled.Contains("erprolename,"))
                {
                    query.Select(p => new { p.ErproleName });
                }
                if (SelectFiled.Contains("erprolepower,"))
                {
                    query.Select(p => new { p.ERProlePower });
                }
            }
            return(query.GetQueryList(connection, transaction));
        }
示例#9
0
 /// <summary>
 /// 数据条数
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>对象列表</returns>
 public int SelectCount(Erpuser model)
 {
     return(ErpuserOper.Instance.SelectCount(model));
 }
示例#10
0
 /// <summary>
 /// 筛选全部数据
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>对象列表</returns>
 public List <Erpuser> SelectByModel(Erpuser model)
 {
     return(ErpuserOper.Instance.SelectAll(model));
 }
示例#11
0
 /// <summary>
 /// 根据模型插入
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public int InsertReturnKey(Erpuser model)
 {
     return(ErpuserOper.Instance.InsertReturnKey(model));
 }
示例#12
0
 /// <summary>
 /// 根据模型插入
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public bool Insert(Erpuser model)
 {
     return(ErpuserOper.Instance.Insert(model));
 }
示例#13
0
 /// <summary>
 /// 根据模型更新
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public bool Update(Erpuser model)
 {
     return(ErpuserOper.Instance.Update(model));
 }
示例#14
0
 /// <summary>
 /// 根据模型删除数据
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public bool DeleteModel(Erpuser model)
 {
     return(ErpuserOper.Instance.DeleteModel(model));
 }
示例#15
0
 /// <summary>
 /// 根据分页筛选数据
 /// </summary>
 /// <param name="Key">主键</param>
 /// <param name="start">开始数据</param>
 /// <param name="PageSize">页面长度</param>
 /// <param name="desc">排序</param>
 /// <param name="model">对象</param>
 /// <returns>对象列表</returns>
 public List <Erpuser> SelectByPage(string Key, int start, int PageSize, bool desc, Erpuser model, string SelectFiled)
 {
     return(ErpuserOper.Instance.SelectByPage(Key, start, PageSize, desc, model));
 }
示例#16
0
        /// <summary>
        /// 根据分页筛选数据
        /// </summary>
        /// <param name="Key">主键</param>
        /// <param name="start">开始数据</param>
        /// <param name="PageSize">页面长度</param>
        /// <param name="desc">排序</param>
        /// <param name="model">对象</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>对象列表</returns>
        public List <Erpuser> SelectByPage(string Key, int start, int PageSize, bool desc = true, Erpuser model = null, string SelectFiled = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var query = new LambdaQuery <Erpuser>();

            if (model != null)
            {
                if (!model.ErproleId.IsNullOrEmpty())
                {
                    query.Where(p => p.ErproleId == model.ErproleId);
                }
                if (!model.ErproleName.IsNullOrEmpty())
                {
                    query.Where(p => p.ErproleName == model.ErproleName);
                }
                if (!model.ERProlePower.IsNullOrEmpty())
                {
                    query.Where(p => p.ERProlePower == model.ERProlePower);
                }
            }
            if (SelectFiled != null)
            {
                SelectFiled = SelectFiled.ToLowerInvariant();
                if (SelectFiled.Contains("erproleid,"))
                {
                    query.Select(p => new { p.ErproleId });
                }
                if (SelectFiled.Contains("erprolename,"))
                {
                    query.Select(p => new { p.ErproleName });
                }
                if (SelectFiled.Contains("erprolepower,"))
                {
                    query.Select(p => new { p.ERProlePower });
                }
            }
            if (Key != null)
            {
                query.OrderByKey(Key, desc);
            }
            return(query.GetQueryPageList(start, PageSize, connection, transaction));
        }