diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs index 77dd165..06a8d73 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs @@ -260,8 +260,11 @@ namespace AIAHTML5.API.Controllers { aar.Add(User["EmailAdd"].ToString()); } - AIAHTML5.API.Models.UserUtility.SendEmail(User, aar, User["EmailAdd"].ToString(), User["reportTitle"].ToString(), User["reportImage"].ToString(), true); - return Request.CreateResponse(HttpStatusCode.OK); + // AIAHTML5.API.Models.UserUtility.SendEmail(User, aar, User["EmailAdd"].ToString(), User["reportTitle"].ToString(), User["reportImage"].ToString(), true); + // return Request.CreateResponse(HttpStatusCode.OK); + bool isEMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(User, aar, User["EmailAdd"].ToString(), User["reportTitle"].ToString(), User["reportImage"].ToString(), true); + // return Request.CreateResponse(HttpStatusCode.OK,); + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(isEMailSent.ToString()) }; } [Route("api/LabExercise/GetParameter")] [HttpGet] diff --git a/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs b/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs index 960420c..1cb33d1 100644 --- a/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs +++ b/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs @@ -31,6 +31,9 @@ namespace AIAHTML5.API.Utility public void SendMail(MailMessage mm) { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + //logger.Debug("inside SendMail"); + try { SmtpClient smtp = new SmtpClient(); @@ -43,7 +46,9 @@ namespace AIAHTML5.API.Utility smtp.Send(mm); } catch (Exception e) - { + { + logger.Fatal("Exception inside SendMail. Ex= " + e.Message + "....STACKTRACE = " + e.StackTrace); + throw; } } @@ -136,7 +141,7 @@ namespace AIAHTML5.API.Utility catch (Exception ex) { logger.Fatal("exception in SendSmtpEmail.msg= " + ex.Message + ", stacktarce= " + ex.StackTrace); - throw ex; + throw ; } } } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index a4a504f..2a312f1 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -1,6 +1,6 @@ /// -AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', '$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", "AIAConstants", -function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService, AIAConstants) { +AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', '$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", "AIAConstants","LoginConstants", +function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService, AIAConstants, LoginConstants) { $scope.$sce = $sce; $scope.LabExerciseName; $scope.LabExerciseQuiz = null; @@ -1409,8 +1409,27 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, return false; } } - - + + $scope.isUserNameValid = false; + var userName = $("#userName").val(); + if (userName.length == 0 || userName == 'undefined' || userName == ' ') { + $("#alertPopUp").css("display", "block"); + $("#messageBody").text("Please enter User name"); + $scope.isUserNameValid = false; + return false; + } + // else { + var filterName = /^([a-zA-Z]+\s?)*$/; + if (filterName.test(userName)) { + $scope.isUserNameValid = true; + } + else { + $("#alertPopUp").css("display", "block"); + $("#messageBody").text("User Name is not valid"); + $scope.isUserNameValid = false; + return false; + } + // } $scope.isReceiverEmailValid = false; var receiverEmail = $("#userEmailID").val(); var rEmail = receiverEmail; @@ -1433,7 +1452,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, // email validation code ends - if ($scope.isSenderEmailValid == true && $scope.isReceiverEmailValid == true) { + if ($scope.isSenderEmailValid == true && $scope.isReceiverEmailValid == true && $scope.isUserNameValid == true) { var reportHtml = ''; @@ -1475,21 +1494,27 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, LabExerciseService.LabExerciseReport(User, $scope.reportImage, $scope.reportTitle, $scope.reportCopyStatus, $scope.receiverEmails).then( - - function (result) { - console.log(result); - }, - function (error) { - console.log(error.statusText); - } -) - // for closing email popup - $rootScope.closeLabExEmailModel(); - - document.getElementById('labExEmailSentModalID').style.display = "block"; - document.getElementById('labExModalbackground').style.display = "block"; - - + function(result){ + if (result == "true") { + document.getElementById('labExEmailSentModalID').style.display = "block"; + document.getElementById('labExModalbackground').style.display = "block"; + + } + else { + var message = LoginConstants.MAIL_NOT_SENT + //alert(message); + $rootScope.errorMessage = message; + $("#messageModal").modal('show'); + } + console.log(result); +}, + function (error) { + var message = LoginConstants.MAIL_NOT_SENT + //alert(message); + $rootScope.errorMessage = message; + $("#messageModal").modal('show'); + console.log(error.statusText); + } } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html index 6479a63..c08a9d6 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html @@ -58,8 +58,8 @@
- -
Please enter your Name
+ +
@@ -168,7 +168,7 @@