public async Task <ActionResult <dynamic> > GetById(int id) { UserEntity entity = new UserEntity(); entity.Username = "******"; entity.Password = "******"; var user = UserRepository.Get(entity.Username, entity.Password); if (user == null) { return(NotFound(new { message = "Usuário ou senha inválidos" })); } var token = new TokenService(); token.GenerateToken(entity); var response = new ConsultaClienteResponse { StatusCode = StatusCodes.Status200OK, Data = new List <Cliente>() }; response.Data.Add(clienteRepository.GetById(id)); return(new { user = user, message = response }); }
public IActionResult GetAll() { var response = new ConsultaClienteResponse { StatusCode = StatusCodes.Status200OK, Data = clienteRepository.GetAll() }; return(Ok(response)); }
public IActionResult GetById(int id) { var response = new ConsultaClienteResponse { StatusCode = StatusCodes.Status200OK, Data = new List <Cliente>() }; response.Data.Add(clienteRepository.GetById(id)); return(Ok(response)); }
/// <summary> /// Consulta de un cliente /// </summary> /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario e información de la consulta</param> /// <returns>Información del cliente en caso de que exista</returns> public ConsultaClienteResponse ConsultaCliente(ConsultaClienteRequest request) { string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name); this.LogRequest(request); ConsultaClienteResponse response = new ConsultaClienteResponse(); string sessionId = this.GetSessionId(request, response, out this.errorMessage); if (this.errorMessage != ErrorMessagesMnemonics.None) { this.LogResponse(response); return(response); } if (!request.IsValidRequest()) { this.SetResponseErrorCode(response, ErrorMessagesMnemonics.InvalidRequiredFields); this.LogResponse(response); return(response); } // Validar en listas restrictivas ErrorMessagesMnemonics errorMessageRestrictiva = ErrorMessagesMnemonics.None; int ocurrenciaListas = this.GetInfoClienteListasRestrictivas(sessionId, request.TipoIdentificacion, request.NumeroIdentificacion, out errorMessageRestrictiva); // Obtener informacion del cliente en BD ErrorMessagesMnemonics errorMessageCliente = ErrorMessagesMnemonics.None; DwhModel.Cliente infoCliente = this.GetInfoCliente(sessionId, request.TipoIdentificacion, request.NumeroIdentificacion, out errorMessageCliente); if (errorMessageRestrictiva != ErrorMessagesMnemonics.None && errorMessageCliente == ErrorMessagesMnemonics.None) { // Cliente en listas restrictivas y enrolado if (request.FechaExpedicion != null && request.FechaExpedicion.HasValue) { if (infoCliente.FechaExpedicion == null && !infoCliente.FechaExpedicion.HasValue) { // Cliente enrolado sin Fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientWithoutDateEspeditionLists); response.Cliente = new DataContract.Cash472.Cliente(); this.EstablecerValoresCliente(response.Cliente, infoCliente); } else if (request.FechaExpedicion.Value.ToString("yyyy-MM-dd").Equals(infoCliente.FechaExpedicion.Value.ToString("yyyy-MM-dd"))) { // Cliente enrolado con la misma fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientInRestrictiveListsAndDatabase); response.Cliente = new DataContract.Cash472.Cliente(); this.EstablecerValoresCliente(response.Cliente, infoCliente); } else { // Cliente enrolado con otra fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientWithAnotherDateEspeditionLists); } } else { // Cliente enrolado no importa la fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientInRestrictiveListsAndDatabase); response.Cliente = new DataContract.Cash472.Cliente(); this.EstablecerValoresCliente(response.Cliente, infoCliente); } } else if (errorMessageRestrictiva != ErrorMessagesMnemonics.None && errorMessageCliente != ErrorMessagesMnemonics.None) { // Cliente en listas restrictivas y no enrolado. this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientInRestrictiveListsAndNotInDatabase); } else if (errorMessageRestrictiva == ErrorMessagesMnemonics.None && errorMessageCliente != ErrorMessagesMnemonics.None) { // Cliente No esta en listas restrictivas y no esta enrolado. this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientNotInRestrictiveListsAndNotInDatabase); } else if (errorMessageRestrictiva == ErrorMessagesMnemonics.None && errorMessageCliente == ErrorMessagesMnemonics.None) { // Cliente No esta en listas restrictivas y enrolado. if (request.FechaExpedicion != null && request.FechaExpedicion.HasValue) { if (infoCliente.FechaExpedicion == null && !infoCliente.FechaExpedicion.HasValue) { // Cliente enrolado con fecha de expedicion null this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientWithoutDateEspeditionNoLists); response.Cliente = new DataContract.Cash472.Cliente(); this.EstablecerValoresCliente(response.Cliente, infoCliente); } else if (request.FechaExpedicion.Value.ToString("yyyy-MM-dd").Equals(infoCliente.FechaExpedicion.Value.ToString("yyyy-MM-dd"))) { // Cliente enrolado con la misma fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientNotInRestrictiveListsAndInDatabase); response.Cliente = new DataContract.Cash472.Cliente(); this.EstablecerValoresCliente(response.Cliente, infoCliente); } else { // Cliente enrolado con otra fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientWithAnotherDateEspeditionNoLists); } } else { // Cliente enrolado no importa la fecha de expedicion this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientNotInRestrictiveListsAndInDatabase); response.Cliente = new DataContract.Cash472.Cliente(); this.EstablecerValoresCliente(response.Cliente, infoCliente); } } else { this.SetResponseErrorCode(response, ErrorMessagesMnemonics.ClientNotInRestrictiveListsAndNotInDatabase); } this.LogResponse(response); return(response); }