Sequencing.WeatherApp.Controllers.OAuth.UserAuthWorker.GetCurrent C# (CSharp) Method

GetCurrent() public method

Returns logged in user data
public GetCurrent ( ) : UserInfo
return Sequencing.WeatherApp.Models.UserInfo
        public UserInfo GetCurrent()
        {
            if (string.IsNullOrEmpty(userNameOvr))
            {
                var _httpCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                var _formsAuthenticationTicket = FormsAuthentication.Decrypt(_httpCookie.Value);

                using (var _ctx = new WeatherAppDbEntities())
                {
                    var _id = long.Parse(_formsAuthenticationTicket.UserData);
                    var _userInfo = _ctx.UserInfo.FirstOrDefault(info => info.Id == _id);
                    return _userInfo;
                }
            }
            else
            {
                using (var _ctx = new WeatherAppDbEntities())
                {
                    var _userInfo = _ctx.UserInfo.Where(info => info.UserName == userNameOvr).OrderByDescending(info => info.Id).First();
                    return _userInfo;
                }
            }
        }