Ejemplo n.º 1
0
        public HttpResponseMessage Post(LoginModel loginModel)
        {
            if (ModelState.IsValid)
            {
                var MOC = new WinStarSoap.MobileOffersClient();

                var winstarDataModel = new WinstarDataModel
                {
                    UserName = loginModel.UserName,
                    Password = loginModel.Password
                };

                int responseValue = MOC.validateUser(
                    winstarDataModel.UserName,
                    winstarDataModel.Password,
                    winstarDataModel.Facility,
                    winstarDataModel.IpAddress);

                //SUCCESS
                if (responseValue == 0)
                {
                    IUserModel currentUser = SecurityHelper.GetWinstarPatron(winstarDataModel);
                    return(Request.CreateResponse(HttpStatusCode.OK, currentUser.ToAuthenticatedUser(winstarDataModel)));
                }

                throw ThrowIfError(responseValue, HttpStatusCode.BadRequest, errors);
            }

            throw ThrowIfError(ERROR_INVALID_LOGIN, HttpStatusCode.BadRequest, errors, ModelState);
        }
        public HttpResponseMessage Post(RegistrationModel dataModel)
        {
            if (ModelState.IsValid)
            {
                var MOC = new WinStarSoap.MobileOffersClient();

                var winstarDataModel = new WinstarDataModel
                {
                    UserName = dataModel.UserName,
                    Password = dataModel.Password
                };

                int responseValue = MOC.createAccount(
                    winstarDataModel.UserName,
                    winstarDataModel.Password,
                    dataModel.PatronNumber,
                    dataModel.Pin,
                    winstarDataModel.Facility,
                    winstarDataModel.IpAddress);

                //SUCCESS
                if (responseValue == 0)
                {
                    IUserModel currentUser = SecurityHelper.GetWinstarPatron(winstarDataModel);
                    return(Request.CreateResponse(HttpStatusCode.OK, currentUser.ToAuthenticatedUser(winstarDataModel)));
                }

                throw ThrowIfError(responseValue, HttpStatusCode.BadRequest, errors);
            }

            throw ThrowIfError(ERROR_GENERIC, HttpStatusCode.BadRequest, errors, ModelState);
        }
Ejemplo n.º 3
0
        public HttpResponseMessage PostEmailAddress(UpdatePatronEmailAddress dataModel)
        {
            if (ModelState.IsValid)
            {
                var MOC = new WinStarSoap.MobileOffersClient();

                var responseValue = MOC.updatePatronEmail
                                    (
                    WinstarDataModel.UserName,
                    WinstarDataModel.Password,
                    WinstarDataModel.Facility,
                    WinstarDataModel.IpAddress,
                    dataModel.NewEmailAddress
                                    );

                if (responseValue > 0)
                {
                    throw ThrowIfError(responseValue, HttpStatusCode.BadRequest, errors);
                }

                IUserModel currentUser = SecurityHelper.GetWinstarPatron(WinstarDataModel);
                return(Request.CreateResponse(HttpStatusCode.OK, currentUser.ToAuthenticatedUser(WinstarDataModel)));
            }

            throw ThrowIfError(ERROR_GENERIC, HttpStatusCode.BadRequest, errors, ModelState);
        }
Ejemplo n.º 4
0
        public HttpResponseMessage PostPassword(UpdatePatronPassword dataModel)
        {
            if (ModelState.IsValid)
            {
                var MOC = new WinStarSoap.MobileOffersClient();

                int responseValue = MOC.resetPatronPassword(dataModel.UserName,
                                                            dataModel.PatronNumber,
                                                            dataModel.Pin,
                                                            ConfigurationManager.AppSettings["Facility"],
                                                            HttpContext.Current.Request.UserHostAddress,
                                                            dataModel.NewPassword);

                if (responseValue > 0)
                {
                    throw ThrowIfError(responseValue, HttpStatusCode.BadRequest, errors);
                }

                var winstarDataModel = new WinstarDataModel
                {
                    UserName = dataModel.UserName,
                    Password = dataModel.NewPassword
                };

                IUserModel currentUser = SecurityHelper.GetWinstarPatron(winstarDataModel);

                return(Request.CreateResponse(HttpStatusCode.OK, currentUser.ToAuthenticatedUser(WinstarDataModel)));
            }

            throw ThrowIfError(ERROR_GENERIC, HttpStatusCode.BadRequest, errors, ModelState);
        }