/// <summary> /// API call to list all Bookings /// </summary> public IEnumerable <BookingVM> GetAllBookings(string status_booking_id = "", string appuser_id = "", string serv_id = "", bool deleted = false) { try { var delString = deleted ? "&deleted=true" : ""; var url = $"{bookPrefix}?status_booking_id={status_booking_id}&serv_id={serv_id}&appuser_id={appuser_id}{delString}"; // Request Base var request = new RestRequest(url, Method.GET) { RequestFormat = DataFormat.Json }; // Ejecutar request y guardar la respuesta var response = client.Execute <List <BookingVM> >(request); // Levanta una excepción si el status code es diferente de 200 CheckStatusCode(response); var bookings = response.Data; // Data para conseguir la información más profunda de la venta var bookStatusList = GetAllBookStatus().ToList(); if (bookStatusList == null) { return(null); } var userList = new UsuariosCaller().GetAllUsers(string.Empty, string.Empty, string.Empty, "ACT").ToList(); if (userList == null) { return(null); } var servList = new ServCaller().GetAllServ(string.Empty, "ACT").ToList(); if (servList == null) { return(null); } bookings.ForEach(book => { book = ProcessBook(book, bookStatusList, userList, servList); }); // Retorna el producto return(bookings); } catch (Exception e) { ErrorWriter.ExceptionError(e); throw e; } }
/// <summary> /// API call to get a Booking /// </summary> /// <param name="bookId"> Booking Id </param> public BookingVM GetBook(string bookId) { if (string.IsNullOrEmpty(bookId)) { ErrorWriter.InvalidArgumentsError(); return(null); } try { var request = new RestRequest($"{bookPrefix}/{bookId}", Method.GET) { RequestFormat = DataFormat.Json }; var response = client.Execute <BookingVM>(request); string notFoundMsg = "La Reserva requerida no existe"; CheckStatusCode(response, notFoundMsg); var book = response.Data; var bookStatusList = GetAllBookStatus().ToList(); if (bookStatusList == null) { return(null); } var userList = new UsuariosCaller().GetAllUsers(string.Empty, string.Empty, string.Empty, "ACT").ToList(); if (userList == null) { return(null); } var servList = new ServCaller().GetAllServ(string.Empty, "ACT").ToList(); if (servList == null) { return(null); } book = ProcessBook(book, bookStatusList, userList, servList); return(book); } catch (Exception e) { ErrorWriter.ExceptionError(e); throw e; } }
/* ---------------------------------------------------------------- */ /* SALE ITEM */ /* ---------------------------------------------------------------- */ /// <summary> /// API call to list all Sale Items of a Sale /// </summary> public IEnumerable <SaleItemVM> GetSaleItems(string saleId) { if (string.IsNullOrEmpty(saleId)) { ErrorWriter.InvalidArgumentsError(); return(null); } try { var request = new RestRequest($"{prefix}/provisions/{saleId}", Method.GET) { RequestFormat = DataFormat.Json }; var response = client.Execute <List <SaleItemVM> >(request); string notFoundMsg = "Items de la venta no encontrados"; CheckStatusCode(response, notFoundMsg); var saleItems = response.Data; var prodList = new ProductosCaller().GetAllProd(string.Empty, string.Empty, string.Empty).ToList(); var delProdList = new ProductosCaller().GetAllProd(string.Empty, string.Empty, string.Empty, true).ToList(); prodList.AddRange(delProdList); var servList = new ServCaller().GetAllServ(string.Empty, string.Empty).ToList(); var delServList = new ServCaller().GetAllServ(string.Empty, string.Empty, true).ToList(); servList.AddRange(delServList); saleItems.ForEach(x => { x = ProcessSaleItem(x, prodList, servList); }); return(saleItems); } catch (Exception e) { ErrorWriter.ExceptionError(e); throw e; } }
/* ---------------------------------------------------------------- */ /* BOOKING RESTRICTION */ /* ---------------------------------------------------------------- */ /// <summary> /// API call to list all Bookings Restrictions /// </summary> public IEnumerable <BookingRestVM> GetAllBookRest(string serv_id = "", bool deleted = false) { try { var delString = deleted ? "&deleted=true" : ""; var url = $"{restPrefix}?serv_id={serv_id}{delString}"; // Request Base var request = new RestRequest(url, Method.GET) { RequestFormat = DataFormat.Json }; // Ejecutar request y guardar la respuesta var response = client.Execute <List <BookingRestVM> >(request); // Levanta una excepción si el status code es diferente de 200 CheckStatusCode(response); var rests = response.Data; var servList = new ServCaller().GetAllServ(string.Empty, "ACT").ToList(); if (servList == null) { return(null); } rests.ForEach(rest => { rest = ProcessRest(rest, servList); }); // Retorna el producto return(rests); } catch (Exception e) { ErrorWriter.ExceptionError(e); throw e; } }
/// <summary> /// API call to get a Booking Restriction /// </summary> /// <param name="restId"> Restriction Id </param> public BookingRestVM GetBookRest(string restId) { if (string.IsNullOrEmpty(restId)) { ErrorWriter.InvalidArgumentsError(); return(null); } try { var request = new RestRequest($"{restPrefix}/{restId}", Method.GET) { RequestFormat = DataFormat.Json }; var response = client.Execute <BookingRestVM>(request); string notFoundMsg = "La Reserva requerida no existe"; CheckStatusCode(response, notFoundMsg); var rest = response.Data; var servList = new ServCaller().GetAllServ(string.Empty, "ACT").ToList(); if (servList == null) { return(null); } rest = ProcessRest(rest, servList); return(rest); } catch (Exception e) { ErrorWriter.ExceptionError(e); throw e; } }