예제 #1
0
        public HttpResponseMessage login(LoginModal model)
        {
            PushNotify _notify = new PushNotify();

            // Check last session exist or not
            if (_userManager.IsAlreadySessionExist(model))
            {
                //remove the all previous sessions of user
                _userManager.ExpirePreviousSessions(model);
                //var lastSession = _userManager.GetLastSessionDetails(model);
                //// if exist then send a notification that your session has expired
                //if (lastSession != null)
                //{

                //if (lastSession.DeviceType == DeviceType.Android)
                //{
                //    var gcmModel = new GCM_Session_Expired()
                //    {
                //        GCM_ID = "GCM_SESSION_EXPIRED",
                //        Message = Messages.GCM_SESSION_EXPIRED
                //    };
                //    var notificationStack = new NotificationStackModel()
                //    {
                //        UserId = lastSession.UserId,
                //        Priority = Priority.High,
                //        Status = BLL.Models.NotificationStatus.Pending,
                //        DeviceId = lastSession.DeviceToken,
                //        Message = gcmModel,
                //    };
                //    var notificatioStack = _notificationStackManager.AddOrUpdateStack(notificationStack);
                //}
                // }
            }
            var result = _userManager.AuthenticateUserOnMobile(model);

            if (result.Status == ActionStatus.Successfull)
            {
                try
                {
                    if (result.Object.DeviceType == (short)DeviceType.IOS)
                    {
                        PushNotifier.NotifyIOSUser(result.Object.DeviceToken, "Login successfully", NotificationType.MessageAlert);
                    }
                }
                catch (Exception ex)
                {
                    _errorLogManager.LogStringExceptionToDatabase(ex.Message);
                }
                return(new JsonContent("Login Successfull", result.Status, result.Object).ConvertToHttpResponseOK());
            }
            return(new JsonContent(result.Message, result.Status).ConvertToHttpResponseOK());
        }
예제 #2
0
        public HttpResponseMessage EditorResponse(EditorModel model)
        {
            var result = new ActionOutput <UserModel>();

            try
            {
                _errorLogManager.LogStringExceptionToDatabase(model.response);
                return(new JsonContent("User Profile", ActionStatus.Successfull, result.Object).ConvertToHttpResponseOK());
            }
            catch (Exception ex)
            {
                return(new JsonContent("Internal Server Error", ActionStatus.Error, null).ConvertToHttpResponseOK());
            }
        }