public HttpResponseMessage PostRetrieveLogin(LoginRetrievalModel loginRetrievalModel) { if (ModelState.IsValid) { var MOC = new WinStarSoap.MobileOffersClient(); var Facility = ConfigurationManager.AppSettings["Facility"]; var IpAddress = HttpContext.Current != null ? HttpContext.Current.Request.UserHostAddress : ""; int responseValue = MOC.retrieveLogin( loginRetrievalModel.PatronNumber, loginRetrievalModel.Pin, Facility, IpAddress); //SUCCESS if (responseValue == 0) { return(Request.CreateResponse(HttpStatusCode.OK)); } throw ThrowIfError(responseValue, HttpStatusCode.BadRequest, errorsLoginRetrieval); } throw ThrowIfError(ERROR_RETRIEVE_LOGIN_INVALID_MODEL, HttpStatusCode.BadRequest, errorsLoginRetrieval, ModelState); }
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 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); }
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); }
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); }
public HttpResponseMessage Get(int year) { var MOC = new WinStarSoap.MobileOffersClient(); var winLossValue = MOC.getWinLoss(WinstarDataModel.UserName, WinstarDataModel.Password, WinstarDataModel.Facility, year.ToString(), WinstarDataModel.IpAddress); IWinLossStatement winLossStatement = new WinLossStatement(); winLossStatement.Year = year; winLossStatement.WinLossValue = winLossValue; return(Request.CreateResponse(HttpStatusCode.OK, winLossStatement)); }
public HttpResponseMessage Get() { var MOC = new WinStarSoap.MobileOffersClient(); var resultsArray = MOC.getSweeps(WinstarDataModel.UserName, WinstarDataModel.Password, WinstarDataModel.Facility, WinstarDataModel.IpAddress); if ((resultsArray != null) && (resultsArray.Length > 0) && (resultsArray[0].error.Length > 0)) { Int32 errorId; Int32.TryParse(resultsArray[0].error, out errorId); throw ThrowIfError(errorId, HttpStatusCode.BadRequest, errors); } return(Request.CreateResponse(HttpStatusCode.OK, resultsArray)); }
/// <summary> /// LOGIN AND AUTHENTICATE USER VIA A LOGIN FORM /// </summary> /// <param name="loginModel"></param> /// <returns></returns> public static IUserModel GetWinstarPatron(IWinstarDataModel dataModel) { var MOC = new WinStarSoap.MobileOffersClient(); var userName = dataModel.UserName; var password = dataModel.Password; var facility = dataModel.Facility; var ipAddress = dataModel.IpAddress; try { WinStarSoap.patron patron = MOC.getPatron(userName, password, facility, ipAddress); IUserModel userModel = new UserModel(); userModel.AcctType = patron.acctType; userModel.DOB = patron.dob; userModel.FirstName = patron.firstName; userModel.MiddleInit = patron.midInit; userModel.LastName = patron.lastName; userModel.PhoneNumber = patron.phone; userModel.MobileNumber = patron.mobile; userModel.EmailAddress = patron.email; userModel.EmailFlag = (patron.emailFlag == "Y"); userModel.AddressLine1 = patron.addr1; userModel.AddressLine2 = patron.addr2; userModel.City = patron.city; userModel.State = patron.state; userModel.Zip = patron.zip; userModel.CashAvailable = patron.cashAvailable; userModel.CurrentCardLevel = patron.currentCardLevel; userModel.CurrentPoints = patron.currentPoints; userModel.PointsAvailable = patron.pointsAvailable; userModel.PointsToNextLevel = patron.pointsToNextLevel; userModel.PointsToNextLevelByDate = patron.pointsToNextLevelByDate; userModel.NextCardLevel = patron.nextCardLevel; userModel.SixMonthADT = patron.sixMonthADT; userModel.Facility = patron.facility; userModel.IsGolfMember = (patron.golfMember == "Y"); userModel.HostFlag = patron.hostFlag; userModel.NewsFlag = patron.newsFlag; userModel.HostName = patron.hostName; userModel.Token = patron.token; userModel.ErrorNumber = patron.error; return(userModel); } catch (Exception ex) { throw new Exception("Error happened retrieving patron", ex); } }
public HttpResponseMessage Get() { var MOC = new WinStarSoap.MobileOffersClient(); var compCashBalanceValue = MOC.getCompCashBalance(WinstarDataModel.UserName, WinstarDataModel.Password, WinstarDataModel.Facility, WinstarDataModel.IpAddress); ICompCashBalanceStatement compCashBalanceStatement = new CompCashBalanceStatement(); compCashBalanceStatement.CompCashBalanceValue = compCashBalanceValue; if (compCashBalanceValue.IndexOf("error") == -1) { return(Request.CreateResponse(HttpStatusCode.OK, compCashBalanceStatement)); } else { Int32 errorId; Int32.TryParse(compCashBalanceValue.Replace("error", ""), out errorId); throw ThrowIfError(errorId, HttpStatusCode.BadRequest, errors); } }