示例#1
0
        // GET: Seller/Acount
        public ActionResult Dashboard()
        {
            if (Session["userID"] != null)
            {
                // kiem tra co phai nhan viên cửa hàng
                if (Convert.ToInt32(Session["roleID"]) != 4)
                {
                    return(View("Login"));
                }
                else if (Convert.ToInt32(Session["roleID"]) == 4)
                {
                    Session["userID"] = 2;
                }
                ProductsClient CC      = new ProductsClient();
                int            Storeid = CC.Storeid(Convert.ToInt32(Session["userID"]));

                //kiem tra role nhan vien thi dang nhap trang shop cua admin
                //if (Convert.ToInt32(Session["role"]) == 4)
                //{
                //    Storeid = CC.Storeid(Convert.ToInt32(Session["AdminShop"]));
                //}

                ViewBag.listProducts = CC.findAll(Storeid);
                return(View());
            }

            else
            {
                return(View("Login"));
            }
        }
示例#2
0
        /// <summary>
        /// Create a new instance of the Pipedrive API v1 client using the specified connection.
        /// </summary>
        /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param>
        public PipedriveClient(IConnection connection)
        {
            Ensure.ArgumentNotNull(connection, nameof(connection));

            Connection = connection;
            var apiConnection = new ApiConnection(connection);

            Activity          = new ActivitiesClient(apiConnection);
            ActivityField     = new ActivityFieldsClient(apiConnection);
            ActivityType      = new ActivityTypesClient(apiConnection);
            Currency          = new CurrenciesClient(apiConnection);
            Deal              = new DealsClient(apiConnection);
            DealField         = new DealFieldsClient(apiConnection);
            File              = new FilesClient(apiConnection);
            Lead              = new LeadsClient(apiConnection);
            Note              = new NotesClient(apiConnection);
            OAuth             = new OAuthClient(connection);
            Organization      = new OrganizationsClient(apiConnection);
            OrganizationField = new OrganizationFieldsClient(apiConnection);
            Person            = new PersonsClient(apiConnection);
            PersonField       = new PersonFieldsClient(apiConnection);
            Pipeline          = new PipelinesClient(apiConnection);
            Product           = new ProductsClient(apiConnection);
            Stage             = new StagesClient(apiConnection);
            User              = new UsersClient(apiConnection);
            Webhook           = new WebhooksClient(apiConnection);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("ID: ");
            int id = Int32.Parse(Console.ReadLine());

            // Take a Category ID and name
            CategoryClient client = new CategoryClient();

            client.Open();
            Console.WriteLine(client.GetCategoryID(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(client.GetCategoryName(id));
            client.Close();

            ProductsClient productClient = new ProductsClient();

            productClient.Open();
            Console.WriteLine(productClient.GetCategoryName(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetProductName(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetProductQty(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetCategoryID(id));
            productClient.Close();

            Console.ReadKey();
        }
        // GET: Seller/Products/Delete/5
        public ActionResult Delete(int id)
        {
            ProductsClient CC = new ProductsClient();

            CC.Delete(id);
            return(RedirectToAction("Index"));
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            int CategoryID = 0;
            int Counter    = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    ProductsClient proxy = new ProductsClient();
                    //CategoryID = proxy.AddCategory("Electronic Products");

                    proxy.AddCategory("Electronic Products");

                    //Counter = proxy.AddProducts(CategoryID);
                    Counter = proxy.AddProducts();

                    MessageBox.Show("Number of Products inserted are : " + Counter.ToString());

                    proxy.Close();
                    ts.Complete();
                }
            }
            catch (FaultException fex)
            {
                MessageBox.Show(fex.Message + "\n\n" +
                                "Products could not be added..");
            }
        }
        public async Task <IActionResult> PutProductsClient(string id, ProductsClient productsClient)
        {
            if (id != productsClient.Id)
            {
                return(BadRequest());
            }

            _context.Entry(productsClient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductsClientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#7
0
        static async Task Main(string[] args)
        {
            var http   = new HttpClient();
            var client = new swaggerClient("http://localhost:5001", http);

            var products = await client.ProductsAllAsync(new ProductFilter());

            foreach (var product in products)
            {
                System.Console.WriteLine(product.Name);
            }

            System.Console.WriteLine("------------");

            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .Build();

            var products_client = new ProductsClient(configuration);

            var pp = products_client.GetProducts();

            foreach (var product in pp.Products)
            {
                System.Console.WriteLine(product.Name);
            }
        }
示例#8
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                var filters = new ProductSearchFilters
                {
                    ExactMatch = true,
                    PageSize   = 1,
                    PageCount  = 1,
                    StartPage  = 0,
                };

                await client.Search("product", filters);

                Received.InOrder(async() =>
                {
                    await connection.SearchAll <SearchResult <SimpleProduct> >(
                        Arg.Is <Uri>(u => u.ToString() == "products/search"),
                        Arg.Is <Dictionary <string, string> >(d => d.Count == 2 &&
                                                              d["term"] == "product" &&
                                                              d["exact_match"] == "True"),
                        Arg.Is <ApiOptions>(o => o.PageSize == 1 &&
                                            o.PageCount == 1 &&
                                            o.StartPage == 0));
                });
            }
示例#9
0
文件: LogIn.cs 项目: kkms30/SmartShop
        public bool CheckLoginData(string id, string password, ref ProductsClient productsClient, ref CashierClient cashierClient, ref Cashier cashier, ref List <Product> products, ref string token)
        {
            token = TokenRequester.ReuqestToken(id, password);
            bool result = false;

            if (token != null)
            {
                cashierClient  = new CashierClient(token);
                productsClient = new ProductsClient(token);

                cashier  = cashierClient.Login(id);
                products = productsClient.GetProducts();
                result   = true;
            }
            else
            {
                result = false;
            }

            if (cashier != null && products.Count > 0 && result)
            {
                result = true;;
            }
            else
            {
                result = false;
            }
            return(result);
        }
示例#10
0
        static void Main(string[] args)
        {
            ProductsClient client   = new ProductsClient();
            string         cateName = client.GetCategoryName(1);

            Console.WriteLine(cateName);
            Console.Read();
        }
示例#11
0
 public AdminProductViewModel()
 {
     if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         ProductList  = new ObservableCollection <ProductData>(ProductsClient.GetProductList());
         CategoryList = new ObservableCollection <CategoryData>(CategoriesClient.GetCategoryList());
     }
 }
示例#12
0
        static void Main(string[] args)
        {
            ProductsClient client      = new ProductsClient();
            string         productName = client.GetProductName(2);

            Console.WriteLine(productName);
            Console.Read();
        }
示例#13
0
        public static async Task Run()
        {
            var client = new ProductsClient();

            var product = await client.GetProductAsync(1);

            Console.WriteLine(product.ProductName);
        }
            public async Task EnsuresSearchTermIsMoreThan3Characters()
            {
                var client = new ProductsClient(Substitute.For <IApiConnection>());

                var exception = await Assert.ThrowsAsync <Exception>(() => client.GetByName("pr", null));

                Assert.Equal("searchTerm must be a minimum of 3 characters in length", exception.Message);
            }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ProductsClient api = new ProductsClient();

            await api.DeleteAsync(id);

            return(RedirectToAction("Index"));
        }
示例#16
0
            public async Task EnsuresSearchTermIsMoreThan2Characters()
            {
                var client = new ProductsClient(Substitute.For <IApiConnection>());

                var exception = await Assert.ThrowsAsync <ArgumentException>(() => client.Search("p", ProductSearchFilters.None));

                Assert.Equal("The search term must have at least 2 characters (Parameter 'term')", exception.Message);
            }
        public ActionResult Edit(int id)
        {
            ProductsClient   CC  = new ProductsClient();
            ProductViewModel CVM = new ProductViewModel();

            CVM.product     = CC.find(id);
            ViewBag.TypeID  = new SelectList(db.Product_Type, "TypeID", "Name", CVM.product.TypeID);
            ViewBag.BrandID = new SelectList(db.Brands, "BrandID", "BrandName", CVM.product.BrandID);
            return(View("Edit", CVM));
        }
示例#18
0
 public ShopyDriver(
     ProductsClient productsClient,
     CategoriesClient categoriesClient,
     SizesClient sizesClient,
     BrandsClient brandsClient)
 {
     _productsClient   = productsClient;
     _categoriesClient = categoriesClient;
     _sizesClient      = sizesClient;
     _brandsClient     = brandsClient;
 }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                await client.GetPermittedUsers(123);

                Received.InOrder(async() =>
                {
                    await connection.Get <IReadOnlyList <long> >(Arg.Is <Uri>(u => u.ToString() == "products/123/permittedUsers"));
                });
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                await client.Get(123);

                Received.InOrder(async() =>
                {
                    await connection.Get <Product>(Arg.Is <Uri>(u => u.ToString() == "products/123"));
                });
            }
            public async Task DeletesCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                await client.DeleteFollower(123, 1234);

                Received.InOrder(async() =>
                {
                    await connection.Delete(Arg.Is <Uri>(u => u.ToString() == "products/123/followers/1234"));
                });
            }
示例#22
0
        public static IShopyDriver GetDriver()
        {
            // TODO: DI this
            var httpClient = new ShopyHttpClient(SettingsHelper.ApiBaseAddress);

            var products   = new ProductsClient(httpClient);
            var categories = new CategoriesClient(httpClient);
            var brands     = new BrandsClient(httpClient);
            var sizes      = new SizesClient(httpClient);

            return(new ShopyDriver(products, categories, sizes, brands));
        }
        public async Task <ActionResult> Delete(int id)
        {
            ProductsClient api = new ProductsClient();

            Product product = api.Get(id);

            if (product == null)
            {
                return(HttpNotFound());
            }

            return(View(product));
        }
示例#24
0
 private static void GetProductQty(int ProductID)
 {
     try
     {
         ProductsClient client     = new ProductsClient();
         int            ProductQty = client.GetProductQty(ProductID);
         Console.WriteLine(string.Format("Product qty {0} for Product ID {1}", ProductQty, ProductID));
     }
     catch (FaultException <ServiceException> ex)
     {
         Console.WriteLine(string.Format("Errors occured in service : {0} ", ex.Detail.Message));
     }
 }
        public async Task <ActionResult> Edit(Product product)
        {
            if (ModelState.IsValid)
            {
                ProductsClient api = new ProductsClient();

                await api.UpdateAsync(product);

                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
示例#26
0
 private static void GetCategoryName(int ProductID)
 {
     try
     {
         ProductsClient client       = new ProductsClient();
         string         CategoryName = client.GetCategoryName(ProductID);
         Console.WriteLine(string.Format("Category name {0} for Product ID {1}", CategoryName, ProductID));
     }
     catch (FaultException <ServiceException> ex)
     {
         Console.WriteLine(string.Format("Errors occured in service : {0} ", ex.Detail.Message));
     }
 }
示例#27
0
        static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .Build();

            var products_client = new ProductsClient(configuration);

            foreach (var product in products_client.GetProducts().Products)
            {
                Console.WriteLine($"{product.Name} - {product.Price}");
            }
        }
            public async Task PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                await client.AddFollower(123, 1234);

                Received.InOrder(async() =>
                {
                    await connection.Post <ProductFollower>(Arg.Is <Uri>(u => u.ToString() == "products/123/followers"),
                                                            Arg.Is <object>(o => o.ToString() == new { user_id = 1234 }.ToString()));
                });
            }
            public async Task RequestsCorrectUrlWithOneParameter()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                await client.GetByName("product");

                Received.InOrder(async() =>
                {
                    await connection.GetAll <SimpleProduct>(Arg.Is <Uri>(u => u.ToString() == "products/find"),
                                                            Arg.Is <Dictionary <string, string> >(d => d.Count == 1 &&
                                                                                                  d["term"] == "product"));
                });
            }
        // GET: Seller/Products
        public ActionResult Index()
        {
            ViewBag.MaintypeID = new SelectList(db.Main_Type, "ID", "Name");
            ViewBag.TypeID     = new SelectList(db.Product_Type, "TypeID", "Name");



            ProductsClient CC      = new ProductsClient();
            int            Storeid = CC.Storeid(Convert.ToInt32(Session["userID"]));

            ViewBag.listProducts = CC.findAll(Storeid);



            return(View());
        }