public JsonResult SaveSolutionFeedback(SolutionFeedback solFeedbackObj, string solutionCode) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); _SearchSolutionBusinessLogic = new SearchSolutionBusinessLogic(); var retObj = _SearchSolutionBusinessLogic.SaveSolutionFeedback(solFeedbackObj, currentUserId, solutionCode); return(Json(true)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }
public bool SaveSolutionFeedback(SolutionFeedback solFeedbackObj, int userId, string solutionCode) { using (TransactionScope scope1 = new TransactionScope()) { try { mongoClient = InitializeMongoClient(); var mongoDatabase = mongoClient.GetDatabase(mongoDBTargetDatabase); string formattedDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); var SolutionCollection = mongoDatabase.GetCollection <SolutionMaster>("SolutionMaster"); var SolutionFeedbackCollection = mongoDatabase.GetCollection <SolutionFeedback>("SolutionFeedback"); //Get the solution Id for the current solution Code int solutionId = SolutionCollection.AsQueryable() .Where(s => s.SolutionCode.ToLower() == solutionCode.ToLower()) .FirstOrDefault().SolutionId; var solutionFeedbackRow = new SolutionFeedback() { SolutionFeedbackId = GetNewSolutionFeedbackID(), UserId = userId, SolutionId = solutionId, IsSolutionCorrect = solFeedbackObj.IsSolutionCorrect, FeedBackComment = solFeedbackObj.FeedBackComment, FeedBackDate = formattedDate, lastModified = DateTime.Now }; SolutionFeedbackCollection.InsertOne(solutionFeedbackRow); scope1.Complete(); return(true); } catch (Exception) { scope1.Dispose(); throw; } } }