public IHttpActionResult OpenDoor() { try { Common.Error response = new Common.Error() { Message = "Hubo un error al abrir la compuerta", HasError = true }; var doorLocker = Helpers.Utilities.GetDoorLockerByName(DoorLockerList.Billetero1); var doorLocker2 = Helpers.Utilities.GetDoorLockerByName(DoorLockerList.Billetero2); if (doorLocker != null && doorLocker2 != null) { _doorLocker = new Libraries.DoorLocker.DoorLocker(doorLocker); _doorLocker.OpenBill(Convert.ToByte(Convert.ToInt32(doorLocker.Id)), Convert.ToByte(Convert.ToInt32(doorLocker2.Id))); var service = _doorLocker.getServiceStatus(); response = service.error; if (service.error.HasError) { _cubiqManagerService.PostLogService(CubiQManagerModel.KioskoService.LOCKERSERVICE, false, service.error.Message); response.Message = "Hubo un error al cominicarse con la puerta"; } } else { _cubiqManagerService.PostLogService(CubiQManagerModel.KioskoService.LOCKERSERVICE, false, "[Billeteros] is null ->Try to open door"); response.HasError = true; response.Message = "Hubo un error al cominicarse con la puerta"; } return(Ok(response)); } catch (Exception e) { return(NotFound()); } }
public IHttpActionResult GetDoorStatus(string door) { try { bool IsOpen = false; Common.Error error = new Common.Error(); var doorLocker = Helpers.Utilities.GetDoorLockerByName(door); if (doorLocker != null) { _doorLocker = new Libraries.DoorLocker.DoorLocker(doorLocker); IsOpen = _doorLocker.IsOpen(Convert.ToByte(Convert.ToInt32(doorLocker.Id))); var service = _doorLocker.getServiceStatus(); if (service.error.HasError) { _cubiqManagerService.PostLogService(CubiQManagerModel.KioskoService.LOCKERSERVICE, false, service.error.Message); error.HasError = true; error.Message = "Hubo un error al cominicarse con la puerta"; } } else { _cubiqManagerService.PostLogService(CubiQManagerModel.KioskoService.LOCKERSERVICE, false, "[" + door + "] is null -> Try to get door status"); error.HasError = true; error.Message = "Hubo un error al cominicarse con la puerta"; } var response = new { error, IsOpen }; return(Ok(response)); } catch (Exception e) { return(NotFound()); } }