コード例 #1
0
ファイル: Restaurant.cs プロジェクト: Ragnarok26/Parrot
 public Response <StoreData> GetStores(string token)
 {
     using (var data = new Data.Restaurant.Restaurant())
     {
         return(data.GetStores(token));
     }
 }
コード例 #2
0
ファイル: Restaurant.cs プロジェクト: Ragnarok26/Parrot
 public Response <object> Validate(string token)
 {
     using (var data = new Data.Restaurant.Restaurant())
     {
         return(data.Validate(token));
     }
 }
コード例 #3
0
ファイル: Restaurant.cs プロジェクト: Ragnarok26/Parrot
 public Response <Product> UpdateProduct(string token, Guid productUuid, string status)
 {
     using (var data = new Data.Restaurant.Restaurant())
     {
         return(data.UpdateProduct(token, productUuid, status == "AVAILABLE" ? "UNAVAILABLE" : "AVAILABLE"));
     }
 }
コード例 #4
0
ファイル: Restaurant.cs プロジェクト: Ragnarok26/Parrot
        public Response <TokenData> Refresh(TokenData tokenData)
        {
            Response <TokenData> response = null;

            using (var data = new Data.Restaurant.Restaurant())
            {
                response = data.Refresh(tokenData);
            }
            if (!string.IsNullOrEmpty(response.Message))
            {
                response.Status = string.Empty;
            }
            return(response);
        }
コード例 #5
0
ファイル: Restaurant.cs プロジェクト: Ragnarok26/Parrot
        public Response <TokenData> Login(User user)
        {
            Response <TokenData> response = null;

            using (var data = new Data.Restaurant.Restaurant())
            {
                response = data.Login(user);
            }
            if (!string.IsNullOrEmpty(response.Message))
            {
                response.Status = string.Empty;
            }
            return(response);
        }
コード例 #6
0
ファイル: Restaurant.cs プロジェクト: Ragnarok26/Parrot
        public Response <Store> GetCategoriesByStore(string token, Store store)
        {
            Response <IEnumerable <Product> > responseProducts = new Response <IEnumerable <Product> >();

            using (var data = new Data.Restaurant.Restaurant())
            {
                responseProducts = data.GetAllProducts(token, store.Uuid);
            }
            Response <Store> response = new Response <Store>
            {
                Message = responseProducts.Message,
                Status  = responseProducts.Status
            };

            if (responseProducts.Success)
            {
                try
                {
                    if (responseProducts.Results.Any())
                    {
                        store.Categories = responseProducts.Results
                                           .GroupBy(
                            product => product.Category.Uuid
                            )
                                           .Select(category => category.First().Category);
                        if (store.Categories.Any())
                        {
                            foreach (var category in store.Categories)
                            {
                                category.Products = responseProducts.Results
                                                    .Where(product => product.Category.Uuid == category.Uuid);
                            }
                        }
                        response.Result = store;
                    }
                    else
                    {
                        response.Result = new Store();
                    }
                }
                catch (Exception ex)
                {
                    response.Message = ex.Message;
                    response.Status  = string.Empty;
                }
            }
            return(response);
        }