//User Get By UserName/EmailId and Paswword
        public List<UserProfileModel> GetUserInfoByUserNamePassword(credentialModel mymodel)
        {
            List<UserProfileModel> model = new List<UserProfileModel>();
            int intValue = 0;
            try
            {
                cmd = new SqlCommand("GetUserInfoByUserNamePassword_Sp", con);
                cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 200).Value = mymodel.UserName;
                cmd.Parameters.Add("@Password", SqlDbType.NVarChar, 150).Value = PasswordSecurity.Encrypt(mymodel.Password);//Password Encryption
                cmd.CommandType = CommandType.StoredProcedure;
                if (con.State == ConnectionState.Closed)
                    con.Open();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    model.Add(new UserProfileModel
                    {
                        UserId = Convert.ToInt32(dr["User_UserId"]),
                        OrgId = Convert.ToInt32(dr["User_OrgId"]),
                        UserFirstName = dr["User_FirstName"].ToString(),
                        UserLastName = dr["User_LastName"].ToString(),
                        UserStreet = dr["User_Street"].ToString(),
                        UserStateId = Convert.ToInt32(dr["User_StateId"]),
                        UserState = dr["User_StateName"].ToString(),
                        UserCityId = Convert.ToInt32(dr["User_CityId"]),
                        UserCity = dr["User_CityName"].ToString(),
                        ProfilePhoto = dr["User_ProfilePhoto"].ToString(),
                        RoleId = Convert.ToInt32(dr["User_RoleId"]),
                        RoleName = dr["User_RoleName"].ToString(),
                        UserName = dr["User_UserName"].ToString(),
                        UserEmailId = dr["User_EmailId"].ToString(),
                        UserMobileNo = dr["User_MobileNo"].ToString(),
                        Password = PasswordSecurity.Decrypt(dr["User_Password"].ToString()),//Password Decryption
                        CreatedBy = Convert.ToInt32(dr["User_CreatedBy"]),
                        CreatedOn = Convert.ToDateTime(dr["User_CreatedOn"]),
                        ModifiedBy = Convert.ToInt32(dr["User_ModifiedBy"]),
                        ModifiedOn = Convert.ToDateTime(dr["User_ModifiedOn"]),
                        IsActive = Convert.ToBoolean(dr["User_IsActive"]),
                        IsDelete = Convert.ToBoolean(dr["User_IsDelete"]),
                        OrgName = dr["Org_Name"].ToString(),
                        OrgStreet = dr["Org_Street"].ToString(),
                        OrgCityId = Convert.ToInt32(dr["Org_CityId"]),
                        OrgCity = dr["Org_CityName"].ToString(),
                        OrgStateId = Convert.ToInt32(dr["Org_StateId"]),
                        OrgState = dr["Org_StateName"].ToString(),
                        RegisteredAs = dr["Org_RegisteredAs"].ToString(),
                        Logo = dr["Org_Logo"].ToString(),
                        OrgCreatedBy = Convert.ToInt32(dr["Org_CreatedBy"]),
                        OrgCreatedOn = Convert.ToDateTime(dr["Org_CreatedOn"]),
                        OrgModifiedBy = Convert.ToInt32(dr["Org_ModifiedBy"]),
                        OrgModifiedOn = Convert.ToDateTime(dr["Org_ModifiedOn"]),
                        Org_IsActive = Convert.ToBoolean(dr["Org_IsActive"]),
                        Org_IsDelete = Convert.ToBoolean(dr["Org_IsDelete"]),
                    });
                    intValue = Convert.ToInt32(dr["User_UserId"]);
                }

                Organization_Sp_Class objOrg = new Organization_Sp_Class();
                LoginDetailModel loginmodel = new LoginDetailModel();
                loginmodel.UserId = intValue;
                objOrg.InsertLoginDetail(loginmodel);

                if (con.State == ConnectionState.Open)
                    con.Close();
            }
            catch (Exception ex)
            {
                obj.Message = ex.Message;
                ret = 0;
            }
            return model;
        }
        public ResponseModel InsertLoginDetail(LoginDetailModel model)
        {
            try
            {
                string strHostName = "";
                string VisitorsIPAddr = "";
                if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
                {
                    VisitorsIPAddr = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                    strHostName = System.Web.HttpContext.Current.Request.UserHostName;
                }
                else if (System.Web.HttpContext.Current.Request.UserHostAddress.Length != 0)
                {
                    VisitorsIPAddr = System.Web.HttpContext.Current.Request.UserHostAddress;
                    strHostName = System.Web.HttpContext.Current.Request.UserHostName;
                }
                cmd = new SqlCommand("InsertLoginDetail_Sp", con);
                if (model.LoginDetailId > 0)
                    cmd.Parameters.Add("@LoginDetailId", SqlDbType.BigInt).Value = model.LoginDetailId;
                cmd.Parameters.Add("@UserId", SqlDbType.BigInt).Value = model.UserId;
                cmd.Parameters.Add("@LoginIp", SqlDbType.NVarChar, 150).Value = VisitorsIPAddr;
                cmd.Parameters.Add("@LogoutIp", SqlDbType.NVarChar, 150).Value = model.LogoutIp;
                cmd.Parameters.Add("@CreatedBy", SqlDbType.BigInt).Value = model.CreatedBy;
                cmd.CommandType = CommandType.StoredProcedure;
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                cmd.ExecuteNonQuery();
                message = "Success";
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                obj.Message = ex.Message;
                ret = 0;
            }
            obj.Response = ret;
            return obj;

        }
 public ResponseModel InsertLoginDetail(LoginDetailModel model)
 {
     return obj.InsertLoginDetail(model);
 }