Esempio n. 1
0
        public loggedUserModel MemberAuthentication(loginUserModel model)
        {
            loggedUserModel UserAuth = null;

            if (model != null)
            {
                using (_ctx = new ApiSecurityEntities())
                {
                    UserAuth = (
                        from u in _ctx.UserAuthentications
                        join r in _ctx.UserRoles on u.RoleID equals r.RoleID
                        where u.LoginID == model.LoginId && u.Password == model.Password && u.StatusID == 1
                        select new
                    {
                        UserId = u.UserID,
                        UserName = u.UserName,
                        Role = r.RoleName,
                        Status = (int)u.StatusID
                    }).Select(x => new loggedUserModel
                    {
                        UserId   = x.UserId,
                        UserName = x.UserName,
                        Role     = x.Role,
                        Status   = (int)x.Status
                    }).FirstOrDefault();
                }
            }
            return(UserAuth);
        }
        public loggedUserModel MemberAuthentication(loginUserModel model)
        {
            loggedUserModel UserAuth = null;

            if (model != null)
            {
                using (_ctx = new ERP_Entities())
                {
                    //UserAuth = (
                    //    from u in _ctx.UserAuthentications
                    //    join r in _ctx.UserRoles on u.RoleID equals r.RoleID
                    //    where u.LoginID == model.LoginId && u.Password == model.Password && u.StatusID == 1
                    //    select new
                    //    {
                    //        UserId = u.UserID,
                    //        UserName = u.UserName,
                    //        Role = r.RoleName,
                    //        Status = (int)u.StatusID
                    //    }).Select(x => new loggedUserModel
                    //    {
                    //        UserId = x.UserId,
                    //        UserName = x.UserName,
                    //        Role = x.Role,
                    //        Status = (int)x.Status

                    //    }).FirstOrDefault();

                    UserAuth = (
                        from u in _ctx.CmnUserAuthentications

                        where u.LoginID == model.LoginId && u.Password == model.Password && u.StatusID == 1
                        select new
                    {
                        UserId = u.UserID,
                        UserName = "******",
                        Role = "Role",
                        Status = (int)u.StatusID
                    }).Select(x => new loggedUserModel
                    {
                        UserId   = x.UserId,
                        UserName = x.UserName,
                        Role     = x.Role,
                        Status   = (int)x.Status
                    }).FirstOrDefault();
                }
            }
            return(UserAuth);
        }
        public JsonResult Login(loginUserModel model)
        {
            objAuth = new UserAuthentications();
            loggedUserModel loggeddata = null; Session["UserSession"] = null;

            try
            {
                if (model != null)
                {
                    loggeddata             = objAuth.MemberAuthentication(model);
                    loggeddata.Ip          = HostService.GetIP();
                    Session["UserSession"] = loggeddata;
                    Session["UserID"]      = loggeddata.UserId;
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(Json(loggeddata, JsonRequestBehavior.AllowGet));
        }