public void GetIpAddressTest() { var expected = "172.0.0.0"; var posId = (byte)1; var actual = _loginManager.GetIpAddress(posId); Assert.AreEqual(expected, actual); }
public HttpResponseMessage GetShifts(UserModel user) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,TillController,GetShifts,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); ErrorMessage errorMessage; if (_loginManager.IsValidUser(user.UserName, user.Password, out errorMessage)) { if (!string.IsNullOrEmpty(_loginManager.GetIpAddress((byte)user.PosId))) { bool shiftsUsedForDay; decimal floatAmount; var shifts = _tillManager.GetShifts(user.UserName, user.TillNumber, user.PosId, out errorMessage, out shiftsUsedForDay, out floatAmount); if (errorMessage.StatusCode == HttpStatusCode.OK && errorMessage.TillNumber != 0) { _performancelog.Debug($"End,TillController,GetShifts,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); //if shift is forced return(Request.CreateResponse(HttpStatusCode.OK, new ActiveShiftResponseModel { Shifts = shifts, ShiftsUsedForDay = shiftsUsedForDay, CashFloat = floatAmount, ForceShift = true })); } //if we get all shifts if (string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { _performancelog.Debug($"End,TillController,GetShifts,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, new ActiveShiftResponseModel { Shifts = shifts, ShiftsUsedForDay = shiftsUsedForDay, CashFloat = floatAmount, ForceShift = false })); } //if there is next shift that can be defined if (shifts != null && shifts.Count != 0) { _performancelog.Debug($"End,TillController,GetShifts,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, new ActiveShiftResponseModel { Shifts = shifts, ShiftsUsedForDay = shiftsUsedForDay, CashFloat = floatAmount, ForceShift = false })); } _performancelog.Debug($"End,TillController,GetShifts,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); //if there is any message return(Request.CreateResponse(errorMessage.StatusCode, new InvalidLoginReponseModel { Error = errorMessage.MessageStyle, ShutDownPOS = errorMessage.ShutDownPos })); } _performancelog.Debug($"End,TillController,GetShifts,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); var store = CacheManager.GetStoreInfo(); var offSet = store?.OffSet ?? 0; //invalid ip address return(Request.CreateResponse(HttpStatusCode.Unauthorized, new InvalidLoginReponseModel() { Error = new MessageStyle { Message = _resourceManager.GetResString(8198, offSet), MessageType = MessageType.OkCancel }, ShutDownPOS = true })); } //invalid user return(Request.CreateResponse(errorMessage.StatusCode, new InvalidLoginReponseModel { Error = errorMessage.MessageStyle, ShutDownPOS = errorMessage.ShutDownPos })); }