Exemplo n.º 1
0
        /// <summary>
        /// Get Data From Database
        /// <para>Use it when to retive data through a stored procedure</para>
        /// </summary>
        public vmAuthenticatedUser Get_CmnUserAuthentication(vmLoginUser model)
        {
            vmAuthenticatedUser objAuthUser = null;
            string spQuery = string.Empty;

            try
            {
                if (model != null)
                {
                    using (GenericFactoryFor_AuthUser = new vmAuthenticatedUser_GF())
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("UserLogin", model.UserLogin.Trim());
                        ht.Add("Password", model.Password.Trim());

                        spQuery     = "[Get_CmnUserAuthentication]";
                        objAuthUser = GenericFactoryFor_AuthUser.ExecuteCommandSingle(spQuery, ht);
                    }
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(objAuthUser);
        }
Exemplo n.º 2
0
        public JsonResult Login(vmLoginUser model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int result = 0; vmAuthenticatedUser objAuthMember = null;
                    objAuthMember = objUserService.Get_CmnUserAuthentication(model);
                    if (objAuthMember != null)
                    {
                        result = Convert.ToInt32(objAuthMember.ReturnValue);
                        if (result == 1)
                        {
                            Session["UserID"]           = objAuthMember.UserID;
                            Session["CompanyID"]        = objAuthMember.CompanyID;
                            Session["CompanyName"]      = objAuthMember.CompanyName;
                            Session["CustomCode"]       = objAuthMember.CustomCode;
                            Session["UserFirstName"]    = objAuthMember.UserFirstName;
                            Session["UserFullName"]     = objAuthMember.UserFullName;
                            Session["UserTypeID"]       = objAuthMember.UserTypeID;
                            Session["UserTypeName"]     = objAuthMember.UserTypeName;
                            Session["UserGroupID"]      = objAuthMember.UserGroupID;
                            Session["GroupName"]        = objAuthMember.GroupName;
                            Session["ClientIP"]         = HostService.GetIP();
                            Session["CompanyShortName"] = objAuthMember.CompanyShortName;
                            string ShortName = objAuthMember.CompanyShortName;
                        }
                    }

                    return(Json(new { status = result }));
                }
                catch (Exception e)
                {
                    return(Json(new { status = false, errors = e.ToString() }));
                }
            }
            return(Json(new
            {
                status = false,
                errors = ModelState.Keys.SelectMany(i => ModelState[i].Errors).Select(m => m.ErrorMessage).ToArray()
            }));
        }