public Response<RespLogin> Login(UserModel objUserModel)
        {
            List<RespLogin> objResp = new List<RespLogin>();
            Response<RespLogin> response = new Response<RespLogin>();
            try
            {
                objDBMethod = new DBMethod();

                if (CheckRequestIsvalidornot(this.Request))
                {
                    objResp.Add(objDBMethod.Login(objUserModel));
                    switch (objResp[0].restKey)
                    {

                        case "0":
                            response.Create(false, Messages.WebError, Messages.AppVersion, objResp);
                            break;
                        case "1":
                            response.Create(true, Messages.FormatMessage(Messages.Success, "Logged in "), Messages.AppVersion, objResp);
                            break;
                        case "2":
                            response.Create(false, Messages.NotAllowedUser, Messages.AppVersion, objResp);
                            break;
                        case "3":
                            response.Create(false, Messages.InvalidPassword, Messages.AppVersion, objResp);
                            break;
                        case "4":
                            response.Create(false, Messages.EmailVerify, Messages.AppVersion, objResp);
                            break;
                        case "5":
                            response.Create(true, Messages.AccountCreated, Messages.AppVersion, objResp);
                            break;
                        case "6":
                            response.Create(false, "Sorry!!! we were unable to fetch your email please change your Facebook settings for email.", Messages.AppVersion, objResp);
                            break;
                        default:
                            response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp);
                            break;
                    }
                }
                else
                {
                    response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp);

                }

            }
            catch (Exception ex)
            {
                object session = new JavaScriptSerializer().Serialize(objUserModel);
                LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message);
                response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp);
            }
            finally
            {
            }
            return response;
        }
        internal RespLogin Custom(UserModel objRequest)
        {
            RespLogin response = new RespLogin();
            tblUser objUser = new tblUser();
            response.restKey = "0";
            if (objRequest.userEmail == null || objRequest.userEmail == "")
            {
                response.restKey = "6";
                return response;
            }
            try
            {
                using (var db = new WizzDataContext())
                {
                    //check normal login or social login
                    if (string.IsNullOrEmpty(objRequest.socialId))
                    {

                    }

                    else
                    {

                        objUser = db.tblUsers.Where(u => u.facebookId == objRequest.socialId).FirstOrDefault();
                        response.userName = Convert.ToString(objRequest.userName);
                        response.profilePic = string.IsNullOrWhiteSpace(objRequest.profilePic) ? "" : objRequest.profilePic.IndexOf("http") >= 0 ? objRequest.profilePic : Constants.imagepath + objRequest.profilePic;
                        //response.profilePic = objRequest.profilePic == null ? "" : objRequest.profilePic;
                        response.userEmail = objRequest.userEmail == null ? "" : objRequest.userEmail;

                        if (objUser == null)// new social id
                        {
                            objUser = db.tblUsers.Where(u => u.userEmail == objRequest.userEmail.ToLower().Trim()).FirstOrDefault();//get existing record against

                            if (objUser == null)// email if not exists
                            {
                                objUser = new tblUser();

                                objUser.createdDate = DateTime.UtcNow;
                                objUser.userName = objRequest.userName == null ? "" : objRequest.userName;
                                objUser.userEmail = objRequest.userEmail == null ? "" : objRequest.userEmail;
                                objUser.registerType = 2;
                                objUser.guid = Guid.NewGuid();
                                objUser.isActive = true;
                                objUser.isDelete = false;
                                objUser.password = Convert.ToString(Guid.NewGuid());
                                objUser.isNotificationOn = true;
                                objUser.referralCode = isReferralCodeExists(objUser.userName);
                                objUser.profilePic = string.IsNullOrWhiteSpace(objRequest.profilePic) ? "" : objRequest.profilePic.IndexOf("http") >= 0 ? objRequest.profilePic : Constants.imagepath + objRequest.profilePic;
                                //  objUser.profilePic = objRequest.profilePic == null ? "" : objRequest.profilePic;
                                objUser.badge = 0;

                                objUser.isFirstTimeLogin = true;
                                objUser.isTeacher = false;
                                objUser.credits = 0;
                                objUser.facebookId = objRequest.socialId.Trim();

                                db.tblUsers.InsertOnSubmit(objUser);
                                //creating a new jabber Id
                                db.SubmitChanges();
                                try
                                {
                                    user jabClient = new user();
                                    jabClient.created_at = DateTime.UtcNow;
                                    jabClient.password = objUser.pkUserId + "@localhost.com";
                                    jabClient.username = objUser.pkUserId.ToString();
                                    db.users.InsertOnSubmit(jabClient);
                                    db.SubmitChanges();
                                }
                                catch (Exception e)
                                {

                                }


                            }

                            objUser.updatedDate = DateTime.UtcNow;
                            objUser.deviceToken = objRequest.deviceToken == null ? "" : objRequest.deviceToken;
                            objUser.deviceType = Convert.ToInt16(objRequest.deviceType);
                            db.SubmitChanges();
                            response.userId = Convert.ToString(objUser.pkUserId);
                            response.restKey = "1";
                            response.credits = Convert.ToString(objUser.credits);
                            response.referralCode = objUser.referralCode;
                            response.isNotificationOn = objUser.isNotificationOn.ToString();
                            response.isFirstimeLogin = objUser.isFirstTimeLogin == null || objUser.isFirstTimeLogin == true ? "True" : "False";
                            response.isTutor = objUser.isTeacher == null || objUser.isTeacher == false ? "False" : "True";

                            response.badge = Convert.ToString(objUser.badge);

                        }
                        else if (objUser.isDelete == true || objUser.isActive == false)
                            response.restKey = "2";

                        else
                        {
                            response.restKey = "1";
                            response.userId = Convert.ToString(objUser.pkUserId);
                            response.userName = Convert.ToString(objUser.userName);
                            response.profilePic = string.IsNullOrWhiteSpace(objUser.profilePic) ? "" : objUser.profilePic.IndexOf("http") >= 0 ? objUser.profilePic : Constants.imagepath + objUser.profilePic;
                            //   response.profilePic = Constants.imagepath + (objUser.profilePic == null ? "" : objUser.profilePic);
                            response.userEmail = objUser.userEmail == null ? "" : objUser.userEmail;
                            response.isNotificationOn = objUser.isNotificationOn.ToString();
                            response.isFirstimeLogin = objUser.isFirstTimeLogin == null || objUser.isFirstTimeLogin == true ? "True" : "False";
                            response.isTutor = objUser.isTeacher == null || objUser.isTeacher == false ? "False" : "True";
                            response.credits = Convert.ToString(objUser.credits);
                            response.badge = Convert.ToString(objUser.badge);
                            response.referralCode = objUser.referralCode;


                        }
                    }

                    if (objUser != null && response.restKey == "1" && (objUser.isFirstTimeLogin == null || objUser.isFirstTimeLogin == true))
                    {
                        objUser.isFirstTimeLogin = false;
                        db.SubmitChanges();
                    }

                    if (!string.IsNullOrEmpty(objRequest.deviceToken))
                    {
                        var objTokenUser = db.tblUsers.Where(s => s.deviceToken == objRequest.deviceToken).FirstOrDefault();
                        if (objTokenUser != null)
                        {
                            objTokenUser.deviceToken = "";
                        }
                        objUser.deviceToken = objRequest.deviceToken;
                        objUser.deviceType = Convert.ToInt16(objRequest.deviceType);
                    }

                    db.SubmitChanges();
                    return response;
                }
            }
            catch
            {
                return response;
            }

        }
        public Response<string> UpdateUser()
        {
            UserModel objReq = new UserModel();
            Response<string> response = new Response<string>();
            List<string> objResp = new List<string>();

            string resp = "";

            try
            {
                objDBMethod = new DBMethod();

                if (CheckRequestIsvalidornot(this.Request))
                {
                    // //HttpContextWrapper objwrapper = GetHttpContext(this.Request);
                    //   HttpFileCollectionBase collection = objwrapper.Request.Files;

                    // string jsonvalue = objwrapper.Request.Form["json"];
                    HttpContextWrapper objwrapper = GetHttpContext(this.Request);
                    HttpFileCollectionBase collection = objwrapper.Request.Files;

                    //var s = HttpContext.Current.Request;
                    //string jsonVlaue = s.Form["json"];
                    //HttpFileCollectionBase o = s.Files;


                    string jsonvalue = objwrapper.Request.Form["json"];
                    if (!string.IsNullOrEmpty(jsonvalue))
                    {
                        objReq = JsonConvert.DeserializeObject<UserModel>(jsonvalue);
                        objReq.profilePic = SaveImage(collection, objReq.profilePic);

                        resp = objDBMethod.UpdateUser(objReq);
                        switch (Convert.ToInt32(resp))
                        {
                            case 0:
                                response.Create(false, "No user found", Messages.AppVersion, objResp);
                                break;
                            case 1:
                                response.Create(true, "Profile updated successfully", Messages.AppVersion, objResp);
                                break;
                            case 2:
                                response.Create(true, "You are blocked from admin", Messages.AppVersion, objResp);
                                break;

                            default:
                                break;
                        }
                    }
                    else
                    {
                        response.Create(false, Messages.InvalidReq, Messages.AppVersion, objResp);
                    }
                }
                else
                {
                    response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp);

                }

            }
            catch (Exception ex)
            {
                object session = new JavaScriptSerializer().Serialize(objReq);
                LogManager.Error(ex.Message, ex, session, ex.Message);
                response.Create(false, "Error occured while Processing Webservice request", Messages.AppVersion, objResp);
            }
            finally
            {
            }
            return response;
        }
        internal string UpdateUser(UserModel objRequest)
        {

            tblUser objUser;
            tblTutorProfile objProfile;
            using (var db = new WizzDataContext())
            {

                objUser = new tblUser();
                long userId = Convert.ToInt64(objRequest.userId);
                objUser = db.tblUsers.FirstOrDefault(x => x.pkUserId == userId);
                if (objUser == null)
                {
                    return "0";
                }
                else if (objUser.isDelete ==true) {

                    return "2";
                }
                else
                {
                    objProfile = new tblTutorProfile();

                    objProfile = db.tblTutorProfiles.Where(x => x.fkUserId == userId).FirstOrDefault();
                    if (objProfile == null)
                    {
                        objProfile = new tblTutorProfile();
                        objProfile.collegeName = objRequest.collageName;
                        objUser.userName = objRequest.userName;

                        //if (objUser.userEmail.ToLower().Trim() == objRequest.userEmail.ToLower().Trim())
                        //{


                        //}
                        //else {
                        //    objUser.userEmail = objRequest.userEmail;
                        //    SendVerifyEmail(objRequest.userEmail, "1", objUser.pkUserId);
                        //}

                        objProfile.description = objRequest.description;
                        objUser.updatedDate = DateTime.UtcNow;
                        objProfile.passingYear = objRequest.passingYear;
                        objUser.profilePic = objRequest.profilePic;
                        objProfile.updatedDate = DateTime.UtcNow;
                        objProfile.createdDate = DateTime.UtcNow;
                        objProfile.fkUserId = userId;
                        db.tblTutorProfiles.InsertOnSubmit(objProfile);

                    }
                    else {

                        objProfile.updatedDate = DateTime.UtcNow;
                        objProfile.createdDate = DateTime.UtcNow;
                        objProfile.collegeName = objRequest.collageName;
                        objUser.userName = objRequest.userName;

                        //if (objUser.userEmail.ToLower().Trim() == objRequest.userEmail.ToLower().Trim())
                        //{


                        //}
                        //else {
                        //    objUser.userEmail = objRequest.userEmail;
                        //    SendVerifyEmail(objRequest.userEmail, "1", objUser.pkUserId);
                        //}

                        objProfile.description = objRequest.description;
                        objUser.updatedDate = DateTime.UtcNow;
                        objProfile.passingYear = objRequest.passingYear;
                        objUser.profilePic = objRequest.profilePic;
                    }
                   
                    db.SubmitChanges();
                    return "1";
                }
            }
        }