public async Task <Response <User> > AddUser(User user)
        {
            var response = new Response <User>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, User>();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           ServiceURIs.Account.AddUser, HttpVerb.Post, user);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #2
0
        public async Task <Response <IEnumerable <Contact> > > GetAll(string username)
        {
            var response = new Response <IEnumerable <Contact> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, IEnumerable <Contact> >();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           $"{ServiceURIs.Contact.GetListContacts}/{username}", HttpVerb.Get);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public async Task <Response <Book> > GetBookByUserId(string userId)
        {
            var response = new Response <Book>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <Book, Book>();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           $"{ServiceURIs.Book.GetBookByUserId}/{userId}", HttpVerb.Get);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public async Task <Response <IEnumerable <Table> > > GetTables(string userId, string establishmentId)
        {
            var response = new Response <IEnumerable <Table> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <IEnumerable <Table>, IEnumerable <Table> >();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           $"{ServiceURIs.Table.GetAllTables}/{userId}/{establishmentId}", HttpVerb.Get);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #5
0
        public async Task <Response <Pager <Combo> > > GetAll(int actualPage = 1, int recordsPerPage = 3)
        {
            var response = new Response <Pager <Combo> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, Pager <Combo> >();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           $"{ServiceURIs.Combo.GetRecordsCombo}?actualPage={actualPage}&recorsPerPage={recordsPerPage}", HttpVerb.Get);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public async Task <Response <User> > GetUserByCredentials(User user, string token)
        {
            var response = new Response <User>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, User>();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           $"{ServiceURIs.Account.GetUserByCredentials}/{user.Username}/{user.Password}", HttpVerb.Get, user, token);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public async Task <Response <Book> > AddBook(Book book)
        {
            var response = new Response <Book>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <Book, Book>();
                var serviceResponse = await client.Consume(new Uri(settings.baseUrl),
                                                           ServiceURIs.Book.AddBook, HttpVerb.Post, book);

                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <string> DeleteDrink(string id)
        {
            var response = new Response <string>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <Drink, string>();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Drink.DeleteDrink}/{id}", HttpVerb.Delete).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <Drink> CreateDrink(Drink book)
        {
            var response = new Response <Drink>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Drink, Drink>();
                var serviceResponse = service.Consume(new Uri(settings.baseUrl),
                                                      $"{ServiceURIs.Drink.CreateDrink}", HttpVerb.Post, book).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <Promotion> CreatePromotion(Promotion promotion)
        {
            var response = new Response <Promotion>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Promotion, Promotion>();
                var serviceResponse = service.Consume(new Uri(settings.baseUrl),
                                                      $"{ServiceURIs.Promotion.CreatePromotion}", HttpVerb.Post, promotion).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #11
0
        public Response <Food> CreateFood(Food food)
        {
            var response = new Response <Food>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Food, Food>();
                var serviceResponse = service.Consume(new Uri(settings.baseUrl),
                                                      $"{ServiceURIs.Food.CreateFood}", HttpVerb.Post, food).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #12
0
        public Response <IEnumerable <Book> > GetBooks(int managerId, int insuranceTypeId)
        {
            var response = new Response <IEnumerable <Book> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <IEnumerable <Book>, IEnumerable <Book> >();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Book.GetAllBooks}/{managerId}/{insuranceTypeId}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #13
0
        public Response <Establishment> GetEstablishmentById(string userId)
        {
            var response = new Response <Establishment>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <Establishment, Establishment>();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Establishment.GetEstablishmentByUserId}/{userId}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <NotificationData> CreateNotification(Notification notification)
        {
            var response = new Response <NotificationData>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Notification, NotificationData>();
                var serviceResponse = service.Consume(new Uri(oneSignal.baseUrl),
                                                      $"{ServiceURIs.Notification.CreateNotification}", HttpVerb.Post, notification, null, true).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <List <Module> > GetModulesByUserId(string userId, string token)
        {
            var response = new Response <List <Module> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <List <Module>, List <Module> >();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Account.GetModulesByUserId}/{userId}", HttpVerb.Get, null, token).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <User> GetUserByCredentials(string user, string password, string token)
        {
            var response = new Response <User>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, User>();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Account.GetUserByCredentials}/{user}/{password}", HttpVerb.Get, null, token).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <string> GetToken(User user)
        {
            var response = new Response <string>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, string>();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Account.GetToken}/", HttpVerb.Post, user).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #18
0
        public Response <IEnumerable <Book> > GetListBooksByBookState(string establishmentId, int bookstate)
        {
            var response = new Response <IEnumerable <Book> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <IEnumerable <Book>, IEnumerable <Book> >();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Book.GetListBooksByBookState}/{establishmentId}/{bookstate}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <Table> GetTableById(int promotionId)
        {
            var response = new Response <Table>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <Table, Table>();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Table.GetTableById}/{promotionId}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <Table> CreateTable(Table table)
        {
            var response = new Response <Table>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Table, Table>();
                var serviceResponse = service.Consume(new Uri(settings.baseUrl),
                                                      $"{ServiceURIs.Table.CreateTable}", HttpVerb.Post, table).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #21
0
        public Response <Food> GetFoodById(string id)
        {
            var response = new Response <Food>()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <Food, Food>();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Food.GetFoodById}/{id}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #22
0
        public Response <Establishment> CreateEstablishment(Establishment establishment)
        {
            var response = new Response <Establishment>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Establishment, Establishment>();
                var serviceResponse = service.Consume(new Uri(settings.baseUrl),
                                                      $"{ServiceURIs.Establishment.CreateEstablishment}", HttpVerb.Post, establishment).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #23
0
        public Response <Book> UpdateBook(string id, Book book)
        {
            var response = new Response <Book>()
            {
                Success = true
            };

            try
            {
                var service         = new HttpClientWrapper <Book, Book>();
                var serviceResponse = service.Consume(new Uri(settings.baseUrl),
                                                      $"{ServiceURIs.Book.UpdateBook}/{id}", HttpVerb.Put, book).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
Beispiel #24
0
        public Response <IEnumerable <Menu> > GetListFoodsByCategory(string establishmentId, string category)
        {
            var response = new Response <IEnumerable <Menu> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, IEnumerable <Menu> >();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Menu.GetListFoodsByCategory}/{establishmentId}/{category}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }
        public Response <IEnumerable <Category> > GetCategoriesHome()
        {
            var response = new Response <IEnumerable <Category> >()
            {
                Success = true
            };

            try
            {
                var client          = new HttpClientWrapper <User, IEnumerable <Category> >();
                var serviceResponse = client.Consume(new Uri(settings.baseUrl),
                                                     $"{ServiceURIs.Category.GetCategoryHome}", HttpVerb.Get).Result;
                response.objectResult = serviceResponse;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error()
                {
                    Message = ex.Message
                };
            }
            return(response);
        }