public ServiceResult <object> LogOut(Clause clause) { try { var userInfo = _userSessionManager.GetUserInfo(clause.Ticket, Request); if (userInfo != null) { using (var unitOfWork = new UnitOfWork()) { var user = unitOfWork.Users.Get(p => p.Username == userInfo.Username.ToLower()) .FirstOrDefault(); if (user != null) { user.LastVisit = DateTime.Now; unitOfWork.Users.Update(user); unitOfWork.Users.Save(); } _memoryCache.Remove("session_" + userInfo.Username); HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); return(new ServiceResult <object>(Enumerator.ErrorCode.UserExpired, "")); } } return(new ServiceResult <object>(Enumerator.ErrorCode.ApplicationError, "کاربری یافت نشد")); } catch (Exception e) { return(new ServiceResult <object>(Enumerator.ErrorCode.ApplicationError, e.Message)); } }