public UserDetails[] ValidateUserLogin(Stream message)
        {

            UserDetails objInput = JSonHelper.JsonDeserialize<UserDetails>(new StreamReader(message).ReadToEnd());
            if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
            {
                var objArray = new UserDetails[1];
                UserDetails objDetails = new UserDetails();
                objDetails.UserId = "";
                objDetails.MessengerMessage = "Invalid PIN";
                objArray[0] = objDetails;
                return objArray;

            }
            if (objInput.Pin != null && objInput.Pin.Length <= 0)
            {
                var objArray = new UserDetails[1];
                UserDetails objDetails = new UserDetails();
                objDetails.UserId = "";
                objDetails.MessengerMessage = "Pin is a required field";
                objArray[0] = objDetails;
                return objArray;
            }
            else
            {
                var objArray = new UserDetails[1];
                UserInfo oUserInfo = new UserInfo();
                oUserInfo.EmailId = objInput.UserName;
                oUserInfo.Password = objInput.Password;
                oUserInfo.pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                UserBLL oUser = new UserBLL();

                int exists = oUser.ValidateUserLogin(ref oUserInfo);

                if (exists == (int)HPFCONNECT.Constants.UserType.Patient)
                {
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.Application = oUserInfo.pin;
                    objDetails.MessengerMessage = "User found";
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.Physician)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.Staff)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.Admin)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.CaseManager)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.CareTransitionCoach)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.CareAdmin)
                {
                    CareAdminInfo oCareAdminInfo = new CareAdminInfo();
                    CareAdminBLL oCareAdminBLL = new CareAdminBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oCareAdminInfo = oCareAdminBLL.getCareAdminDetailsByEmailID(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oCareAdminInfo.CareManagerID;
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.CareCoordinator)
                {
                    CareAdminInfo oCareAdminInfo = new CareAdminInfo();
                    CareAdminBLL oCareAdminBLL = new CareAdminBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oCareAdminInfo = oCareAdminBLL.getCareAdminDetailsByEmailID(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oCareAdminInfo.CareManagerID;
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.Hospital)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.CareOperator)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.Billing)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    UserInfo oUserInfoID = new UserInfo();
                    UserBLL oUserId = new UserBLL();
                    oPhysicianInfo = oPhysician.getBillingDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oUserInfo.UserId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                else if (exists == (int)HPFCONNECT.Constants.UserType.SystemAdmin)
                {
                    PhysicianInfo oPhysicianInfo = new PhysicianInfo();
                    PhysicianBLL oPhysician = new PhysicianBLL();
                    oPhysicianInfo = oPhysician.getPhysicianDetailsByEmailId(oUserInfo.EmailId, oUserInfo.pin);
                    UserDetails objDetails = new UserDetails();
                    objDetails.UserId = "";
                    objDetails.MessengerMessage = "User found";
                    objDetails.PhysicianId = oPhysicianInfo.PhysicianId;
                    objDetails.IsAdmin = oPhysicianInfo.IsAdmin.ToString();
                    objDetails.IsSuperUser = oPhysicianInfo.IsSuperUser.ToString();
                    objDetails.IsStaff = oPhysicianInfo.IsStaff.ToString();
                    objDetails.UserId = oPhysicianInfo.PhysicianId.ToString();
                    objDetails.Application = oUserInfo.pin;
                    objDetails.UserType = exists;
                    objArray[0] = objDetails;
                    return objArray;
                }
                UserDetails objDetails3 = new UserDetails();
                objDetails3.UserId = "";
                objDetails3.MessengerMessage = "User not found";
                objArray[0] = objDetails3;
                return objArray;
            }
        }