コード例 #1
0
ファイル: DBMethod.cs プロジェクト: rjdeveloper/bigdecimalweb
        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;
            }

        }
コード例 #2
0
ファイル: DBMethod.cs プロジェクト: rjdeveloper/bigdecimalweb
        //internal SettingModel GetSetting(ReqSetting objRequest)
        //{
        //    //System.Data.Entity.Core.Objects.ObjectParameter UpdatedLastSyncTime = new System.Data.Entity.Core.Objects.ObjectParameter("UpdatedLastSyncTime", typeof(string));
        //    string UpdatedLastSyncTime = "";
        //    SettingModel response = new SettingModel();

        //    using (var db = new WizzDataContext())
        //    {
        //        db.usp_isUpdatedData(objRequest.lastSyncTime, ref UpdatedLastSyncTime);


        //        if (string.IsNullOrEmpty(UpdatedLastSyncTime))
        //        {
        //            response.lastSyncTime = objRequest.lastSyncTime;
        //            return response;
        //        }
        //        else
        //        {
        //            response.lastSyncTime = UpdatedLastSyncTime;
        //            response.isUpdated = "True";
        //        }

        //        //get admin setting
        //        var setting = db.tblSettings.FirstOrDefault();
        //        if (setting != null)
        //        {
        //           // response.comission = setting.commission == null ? "" : Convert.ToString(setting.commission);
        //          //  response.feePerHour = setting.perHourFees == null ? "" : Convert.ToString(setting.perHourFees);
        //          //  response.feePerStudent = setting.perStudentCharge == null ? "" : Convert.ToString(setting.perStudentCharge);
        //        }


        //        //}

        //    }
        //    return response;
        //}


        
        internal RespLogin GetUser(Entity objRequest)
        {
            RespLogin response = new RespLogin();
            using (var db = new WizzDataContext())
            {
                var userId = Convert.ToInt64(objRequest.userId);
                var objUser = db.tblUsers.Where(u => u.pkUserId == userId).FirstOrDefault();
                var userProfile = db.tblTutorProfiles.Where(x => x.fkUserId == userId).FirstOrDefault();
                if (objUser != null)
                {
                    if (userProfile == null) {

                        response.restKey = "3";
                        return response;
                    }

                    response.restKey = "1";
                    response.userId = Convert.ToString(objUser.pkUserId);
                    response.userName = Convert.ToString(objUser.userName);
                    if (objUser.profilePic != null || objUser.profilePic != "")
                    {
                        if (objUser.profilePic.Contains("http") || objUser.profilePic.Contains("Http") || objUser.profilePic.Contains("https"))
                        {
                            response.profilePic = objUser.profilePic;
                        }
                        else
                        {
                            response.profilePic = Constants.imagepath + objUser.profilePic;

                        }

                    }
                    else
                    {
                        response.profilePic = "";
                    }
                    //  response.profilePic = objUser.profilePic == null ? "" : objUser.profilePic;
                    response.userEmail = objUser.userEmail == null ? "" : objUser.userEmail;
                    //response.isNotificationOn = objUser.isNotificationOn.ToString();
                    //response.credits = Convert.ToString(objUser.credits);
                    //response.isFirstimeLogin = objUser.isFirstTimeLogin == null || objUser.isFirstTimeLogin == true ? "True" : "False";
                    //response.badge = objUser.badge.ToString();
                    //response.badge = objUser.badge.ToString();
                    //response.isTutor = objUser.isTeacher == null || objUser.isTeacher == false ? "False" : "True";
                    response.collageName = userProfile.collegeName;
                    response.passingYear = userProfile.passingYear;
                    response.description = userProfile.description;
                    response.referralCode = objUser.referralCode;

                }
            }
            return response;
        }