public JsonResult UpdateProfile(string SessionGuid, UserInfo Profile) { try { var response = Profile; var validSession = DbHelpers.SessionIsValid(SessionGuid); if (!validSession) { return(Json( new JsonResponse <bool> { Response = false, Success = false, Message = "Invalid Session. Try logging out and then loggin back in. No changes were saved." }, JsonRequestBehavior.AllowGet )); } bool Success = false; if (Profile == null) { return(Json( new JsonResponse <bool> { Response = Success, Success = false, Message = "Profile==null" }, JsonRequestBehavior.AllowGet )); } UserInfo.Save(Profile); Success = true; return(Json( new JsonResponse <bool> { Response = Success, Success = true, Message = "User Updated!" }, JsonRequestBehavior.AllowGet )); } catch (Exception e) { return(Json( new JsonResponse <bool> { Response = false, Success = false, Message = e.Message }, JsonRequestBehavior.AllowGet )); } }
public JsonResult AddTest(string SessionGuid, Test Test) { try { var validSession = DbHelpers.SessionIsValid(SessionGuid); if (!validSession) { return(Json( new JsonResponse <bool> { Response = false, Success = false, Message = "Invalid Session. Try logging out and then loggin back in. No changes were saved." }, JsonRequestBehavior.AllowGet )); } bool Success = false; if (Test == null) { return(Json( new JsonResponse <bool> { Response = Success, Success = false, Message = "Test==null" }, JsonRequestBehavior.AllowGet )); } Success = DbHelpers.AddTest(Test); return(Json( new JsonResponse <bool> { Response = Success, Success = Success, Message = Success?"Test added!": "An error occurred while adding the test." }, JsonRequestBehavior.AllowGet )); } catch (Exception e) { return(Json( new JsonResponse <bool> { Response = false, Success = false, Message = e.Message }, JsonRequestBehavior.AllowGet )); } }