Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ==================================JS===========================================
- var user = Ext.Ajax.request({
- method: 'GET',
- url: '/UserAccount/GetUserData',
- success: function (response) {
- user = Ext.util.JSON.decode(response.responseText).results;
- Ext.getCmp('user-name').setHtml(user.Username);
- var image = new Image();
- image.src = 'data:image/png;base64,' + user.ProfilePictureString;
- var e = Ext.getCmp('dashboard-profile-picture');
- e.setSrc(image.src);
- }
- });
- ==============================================================================
- =========================== C# ===========================================
- public ActionResult GetUserData()
- {
- if (Session["user"] != null)
- {
- Response.StatusCode = (int)HttpStatusCode.OK;
- var results = new UserRepository().GetUserInfo(Session["user"].ToString());
- return Json(new { results }, JsonRequestBehavior.AllowGet); //TODO: add code for sending back the navigation data
- }
- Response.StatusCode = (int)HttpStatusCode.Unauthorized;
- return Json("Unauthorised access at this point, you must be logged into an account!");
- }
- in other c# file
- public User GetUserInfo(string name)
- {
- var _db = base.GetDatabaseConnection();
- if (!String.IsNullOrWhiteSpace(name))
- {
- return _db.SingleOrDefault<User>("WHERE username = @0", name);
- }
- else
- {
- return null;
- }
- }
- ==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement