Ejemplo n.º 1
0
        public HttpResponseMessage GetPassword(string userName)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,LoginController,GetPassword,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            if (!string.IsNullOrEmpty(userName))
            {
                ErrorMessage errorMessage;
                var          password = _loginManager.GetPassword(userName, out errorMessage);
                _performancelog.Debug($"End,LoginController,GetPassword,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
                if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
                {
                    //if there is any message
                    return(Request.CreateResponse(errorMessage.StatusCode,
                                                  new InvalidLoginReponseModel
                    {
                        Error = errorMessage.MessageStyle,
                        ShutDownPOS = errorMessage.ShutDownPos
                    }));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, password));
            }
            _performancelog.Debug($"End,LoginController,GetPassword,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            var error = new InvalidLoginReponseModel
            {
                Error = new MessageStyle
                {
                    Message     = Resource.InvalidInformation,
                    MessageType = MessageType.OkOnly
                },
                ShutDownPOS = true
            };

            return(Request.CreateResponse(HttpStatusCode.BadRequest, error));
        }