Exemple #1
0
        /// <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;
            }
        }
Exemple #2
0
        /// <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;
            }
        }
Exemple #3
0
        /// <summary>
        /// API call to get a Sale
        /// </summary>
        /// <param name="saleId"> Sale Id </param>
        public SaleVM GetSale(string saleId)
        {
            if (string.IsNullOrEmpty(saleId))
            {
                ErrorWriter.InvalidArgumentsError();
                return(null);
            }

            try
            {
                var request = new RestRequest($"{salesPrefix}/{saleId}", Method.GET)
                {
                    RequestFormat = DataFormat.Json
                };

                var response = client.Execute <SaleVM>(request);

                string notFoundMsg = "La venta requerida no existe";
                CheckStatusCode(response, notFoundMsg);


                var sale = response.Data;

                var saleStatusList = GetAllStatus().ToList();
                if (saleStatusList == null)
                {
                    return(null);
                }

                var userList = new UsuariosCaller().GetAllUsers(string.Empty, string.Empty, string.Empty, "ACT").ToList();

                sale = ProcessSale(sale, saleStatusList, userList);

                // Agregar los Items de la venta ya que es el detalle
                var saleItems = GetSaleItems(sale.sale_id);
                sale.saleItems = saleItems.ToList();

                return(sale);
            }
            catch (Exception e)
            {
                ErrorWriter.ExceptionError(e);
                throw e;
            }
        }
Exemple #4
0
        /// <summary>
        /// API call to list all Sales
        /// </summary>
        public IEnumerable <SaleVM> GetAllSales(string code, string sale_status_id, bool deleted = false, string id_cashier = "", string id_seller = "", string id_appuser = "")
        {
            try
            {
                var delString = deleted ? "&deleted=true" : "";
                var url       = $"{salesPrefix}?code={code}&id_cashier={id_cashier}&id_seller={id_seller}&id_appuser={id_appuser}&sale_status_id={sale_status_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 <SaleVM> >(request);

                // Levanta una excepción si el status code es diferente de 200
                CheckStatusCode(response);

                var sales = response.Data;

                // Data para conseguir la información más profunda de la venta
                var saleStatusList = GetAllStatus().ToList();
                if (saleStatusList == null)
                {
                    return(null);
                }

                var userList = new UsuariosCaller().GetAllUsers(string.Empty, string.Empty, string.Empty, "ACT").ToList();

                sales.ForEach(sale =>
                {
                    sale = ProcessSale(sale, saleStatusList, userList);
                });

                // Retorna las ventas
                return(sales);
            }
            catch (Exception e)
            {
                ErrorWriter.ExceptionError(e);
                throw e;
            }
        }