From ad5a3a1ff4e029c66fb3437d687f1f956e5d7caa Mon Sep 17 00:00:00 2001 From: nikita Date: Tue, 31 Mar 2020 19:23:27 +0530 Subject: [PATCH] commit --- 400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs | 31 ++++++++++++++++++++++--------- 400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs | 35 ++++++++++------------------------- 400-SOURCECODE/AIAHTML5.API/Models/User.cs | 4 ++++ 400-SOURCECODE/AIAHTML5.Web/Web.config | 6 +++--- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- 400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js | 23 +++++++++++++++++++++++ 6 files changed, 141 insertions(+), 57 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs index 1f29337..83ddbbb 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs @@ -261,10 +261,24 @@ namespace AIAHTML5.API.Controllers } // get exported image detail - userInfo.UserExportImageDetail = GetLicenseExportImageDetail(userInfo.LicenseId); - // GetUserSelectedSettings(userInfo); + } + //get use settings + string skintone; + string modesty; + User us = AIAHTML5.API.Models.Users.GetUserSelectedSettings(userInfo.Id, out skintone, out modesty); + if (us != null) + { + userInfo.userselectedModesty = modesty; + userInfo.userSelectedSkintone = skintone; + } + else + { + userInfo.userselectedModesty = null; + userInfo.userSelectedSkintone = null; + + } } private static void CheckLicenseStatus(User userInfo) @@ -365,7 +379,7 @@ namespace AIAHTML5.API.Controllers [HttpPost] - [Route("api/Configuration/SaveUserSettings")] + [Route("api/SaveUserSettings")] public HttpResponseMessage SaveUserSettings([FromBody]JObject jsonData) { int Status = 0; @@ -374,14 +388,13 @@ namespace AIAHTML5.API.Controllers try { - settings.userselectedModesty = jsonData["Modesty"].Value(); - settings.Id = jsonData["UserId"].Value(); - - settings.userSelectedSkintone = jsonData["skintone"].Value(); + settings.userselectedModesty =jsonData["modesty"].Value(); + settings.userSelectedSkintone = jsonData["skintone"].Value(); settings.userSelectedFont = null; + settings.Id= jsonData["userId"].Value(); Status = AIAHTML5.API.Models.Users.SaveUserSelectedSettings(settings); - if (Status == -1) + if (Status == 1) { responseData = "1"; @@ -391,7 +404,7 @@ namespace AIAHTML5.API.Controllers { responseData = AIAConstants.SETTINGS_SAVE_FAILURE; } - return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent(responseData) }; + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(responseData) }; } catch (Exception ex) diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index 1d66eac..a42c72d 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -310,9 +310,9 @@ namespace AIAHTML5.API.Models return objUser; } - internal static User GetSelectedSettings(int userId) + internal User GetSelectedSettings(int userId) { - logger.Debug(" Inside GetSelectedSettings for emailId = " + userId); + logger.Debug(" Inside GetSelectedSettings for userId = " + userId); User objUser = null; DBModel objModel = new DBModel(); @@ -327,9 +327,9 @@ namespace AIAHTML5.API.Models cmd.CommandText = DBConstants.GET_SETTINGS; cmd.CommandType = CommandType.StoredProcedure; - param = new SqlParameter("@sEmailId", emailId); + param = new SqlParameter("@iUserId", userId); param.Direction = ParameterDirection.Input; - param.DbType = DbType.String; + param.DbType = DbType.Int32; cmd.Parameters.Add(param); adapter = new SqlDataAdapter(cmd); @@ -344,27 +344,12 @@ namespace AIAHTML5.API.Models { foreach (DataRow dr in dt.Rows) { - int tempVal; - DateTime date; objUser = new User(); - objUser.Id = Convert.ToInt32(dr["Id"]); - objUser.FirstName = dr["FirstName"].ToString(); - objUser.LastName = dr["LastName"].ToString(); - objUser.EmailId = dr["EmailId"].ToString(); - objUser.LoginId = dr["LoginId"].ToString(); - objUser.Password = dr["Password"].ToString(); - objUser.SecurityQuestionId = Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null; - objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ; - objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null; - objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]); - objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null; - objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null; - objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; - objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]); - objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"])); - objUser.IsActive = Convert.ToBoolean(dr["IsActive"]); - logger.Debug("objUser.Id= " + objUser.Id + ",objUser.FirstName= " + objUser.FirstName + ",objUser.LoginId= " + objUser.LoginId + ",objUser.Password= " + objUser.Password + ",objUser.SecurityQuestionId= " + objUser.SecurityQuestionId); + objUser.Id = Convert.ToInt32(dr["UserId"]); + objUser.userSelectedSkintone = dr["Skintone"].ToString(); + objUser.userselectedModesty = dr["Modesty"].ToString(); + logger.Debug("objUser.Id= " + objUser.Id + ",objUser.userselectedModesty= " + objUser.userselectedModesty + ",objUser.userSelectedSkintone= " + objUser.userSelectedSkintone + ",objUser.Password= " + objUser.Password + ",objUser.SecurityQuestionId= " + objUser.SecurityQuestionId); } } } @@ -717,14 +702,14 @@ namespace AIAHTML5.API.Models cmd.Parameters.AddWithValue("@iUserId", settings.Id); cmd.Parameters.AddWithValue("@iModesty", settings.userselectedModesty); cmd.Parameters.AddWithValue("@iSkintone",settings. userSelectedSkintone); - // cmd.Parameters.AddWithValue("@ifont", ); + cmd.Parameters.AddWithValue("@ifont","" ); result = cmd.ExecuteNonQuery(); } catch (SqlException ex) { - logger.Fatal("Exception in InsertLoginDetails for UserId= " + userId + ", Exception= " + ex.Message + ", STACKTRACE=" + ex.StackTrace); + logger.Fatal("Exception in InsertLoginDetails for UserId= " + settings.Id + ", Exception= " + ex.Message + ", STACKTRACE=" + ex.StackTrace); throw; } finally diff --git a/400-SOURCECODE/AIAHTML5.API/Models/User.cs b/400-SOURCECODE/AIAHTML5.API/Models/User.cs index 862e67b..c6ba4ab 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/User.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/User.cs @@ -39,6 +39,10 @@ namespace AIAHTML5.API.Models public ArrayList Modules { get; set; } public int siteId { get; set; } public string pwd { get; set; } + public String userSelectedSkintone { get; set; } + public string userselectedModesty { get; set; } + public string userSelectedFont { get; set; } + public License LicenseInfo { get; set; } public LicenseSubscriptionDetails LicenseSubscriptions { get; set; } diff --git a/400-SOURCECODE/AIAHTML5.Web/Web.config b/400-SOURCECODE/AIAHTML5.Web/Web.config index 385bad9..ce5f978 100644 --- a/400-SOURCECODE/AIAHTML5.Web/Web.config +++ b/400-SOURCECODE/AIAHTML5.Web/Web.config @@ -21,7 +21,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 9170426..e7b129e 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -548,36 +548,65 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data //code for modesty setting if (result.LicenseInfo != null) { - if (result.IsModestyOn) { - $rootScope.isModestyOn = true; - $rootScope.isModestyOff = false; - localStorage.setItem("globalModesty", "Y"); - $rootScope.formsetting = { - ethnicity: null, - modesty: "Y" + if (result.userselectedModesty == undefined || result.userselectedModesty == null || + result.userSelectedSkintone == undefined || result.userSelectedSkintone == null) { + if (result.IsModestyOn) { + $rootScope.isModestyOn = true; + $rootScope.isModestyOff = false; + localStorage.setItem("globalModesty", "Y"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "Y" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + else { + $rootScope.isModestyOn = false; + $rootScope.isModestyOff = true; + localStorage.setItem("globalModesty", "N"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "N" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) } - $rootScope.UpdateAndCloseSetting($rootScope.formsetting) } else { - $rootScope.isModestyOn = false; - $rootScope.isModestyOff = true; - localStorage.setItem("globalModesty", "N"); + localStorage.setItem("globalModesty", result.userselectedModesty); + localStorage.setItem("globalEthnicity", result.userSelectedSkintone); + $rootScope.formsetting = { - ethnicity: null, - modesty: "N" + ethnicity: result.userSelectedSkintone, + modesty: result.userselectedModesty } $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } } else { - $rootScope.isModestyOn = true; - $rootScope.isModestyOff = false; - localStorage.setItem("globalModesty", "Y"); - $rootScope.formsetting = { - ethnicity: null, - modesty: "Y" + if (result.userselectedModesty == undefined || result.userselectedModesty == null || + result.userSelectedSkintone == undefined || result.userSelectedSkintone == null) { + + $rootScope.isModestyOn = true; + $rootScope.isModestyOff = false; + localStorage.setItem("globalModesty", "Y"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "Y" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting); + } + else { + localStorage.setItem("globalModesty", result.userselectedModesty); + localStorage.setItem("globalEthnicity", result.userSelectedSkintone); + + $rootScope.formsetting = { + ethnicity: result.userSelectedSkintone, + modesty: result.userselectedModesty + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } - $rootScope.UpdateAndCloseSetting($rootScope.formsetting) } //code for modesty setting $rootScope.aiaModesty = $rootScope.formsetting.modesty; @@ -5974,6 +6003,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $rootScope.CloseSetting = function () { // $rootScope.errorMessage = LoginMessageConstants.INVALID_USER; $("#saveSettingsMessageModal").modal('show'); + $("#saveSettingsMessageModal").css('zIndex', 80000000000); //$('#modal-settings').css("display", "none"); //$("#modelsettingsbackground").css("display", "none"); } @@ -5981,7 +6011,36 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data var currentSkintone = $rootScope.globalSetting.ethnicity; var currentModesty = $rootScope.globalSetting.modesty; + var setting={}; + setting.modesty =currentModesty ; + setting.skintone = currentSkintone; + setting.userId = $rootScope.userData.Id; + AuthenticationService.saveSetings(setting) + .then( + + function (result) { + var k= result; + if(result==1){ + $rootScope.errorMessage = AIAConstants.SETTINGS_SAVED ; + $('#modal-settings').css("display", "none"); + $("#modelsettingsbackground").css("display", "none"); + } + else{ + $rootScope.errorMessage =AIAConstants.SETTING_SAVE_ERROR; + + } + $("#messageModal").css('zIndex', 80000000000); + $("#messageModal").modal('show'); + + }), + function (error) { + console.log(' Error in Saving settings = ' + error.statusText); + // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = error; + $("#messageModal").modal('show'); + } } $rootScope.UpdateAndCloseSetting = function (setting) { diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index 8d36352..d803100 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -43,6 +43,29 @@ return deferred.promise; }, + + saveSetings: function (settings) { + var deferred = $q.defer(); + + $http.post('/API/api/SaveUserSettings', JSON.stringify(settings), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + + }); + return deferred.promise; + }, + + validateClientSite: function (clientInfo) { var deferred = $q.defer(); -- libgit2 0.21.4