public static async Task <ServerResponse <object, ProductErrorMessage> > CreateProduct(byte[] productImage, string fileName, Product product)
        {
            MultipartFormDataContent form = new MultipartFormDataContent();

            form.Add(new ByteArrayContent(productImage, 0, productImage.Length), "ProductImageFile", Regex.Replace(fileName, @"[\(\)]", "_"));
            form.Add(new StringContent(product.ProductName), "ProductName");
            form.Add(new StringContent(product.Price.ToString()), "Price");
            form.Add(new StringContent(product.CatalogId.ToString()), "CatalogId");

            return(await FetchApi.PostMultipartAsync <ProductErrorMessage>("products", form));
        }
示例#2
0
        public static async Task <List <User> > GetAllUsers(string role)
        {
            var res = await FetchApi.GetAsync <List <User>, UserErrorMessage>("user");

            if (res == null || !res.IsSuccess)
            {
                return(null);
            }

            List <User> users = new List <User>();

            foreach (User item in res.Data)
            {
                if (item.RoleName.Equals(role))
                {
                    users.Add(item);
                }
            }

            return(users);
        }
        public static async Task <ServerResponse <List <Catalog>, CatalogErrorMessage> > GetAllCatalogs()
        {
            var res = await FetchApi.GetAsync <List <Catalog>, CatalogErrorMessage>("catalogs");

            return(res);
        }
示例#4
0
 public static async Task <ServerResponse <User, UserErrorMessage> > Login(string email, string password)
 {
     return(await FetchApi.PostAsync <User, UserErrorMessage>("user/login", new { email, password }));
 }
示例#5
0
        public static async Task <ServerResponse <Combo, ComboErrorMessage> > GetComboByID(int comboID)
        {
            var res = await FetchApi.GetAsync <Combo, ComboErrorMessage>($"combos/{comboID}");

            return(res);
        }
 public static async Task <ServerResponse <object, OrderErrorMessage> > DeleteOrder(int orderID)
 {
     return(await FetchApi.DeleteAsync <OrderErrorMessage>($"orders/{orderID}"));
 }
 public static async Task <ServerResponse <object, OrderErrorMessage> > CreateOrder(CreateOrderDTO order)
 {
     return(await FetchApi.PostAsync <OrderErrorMessage>("orders", order));
 }
        public static async Task <ServerResponse <List <Order>, OrderErrorMessage> > GetAllOrders()
        {
            var res = await FetchApi.GetAsync <List <Order>, OrderErrorMessage>("orders");

            return(res);
        }
 public static async Task <ServerResponse <object, CatalogErrorMessage> > UpdateCatalog(int catalogID, Catalog catalog)
 {
     return(await FetchApi.PutAsync <CatalogErrorMessage>("catalogs/" + catalogID, catalog));
 }
 public static async Task <ServerResponse <object, ProductErrorMessage> > DeleteProduct(int productID)
 {
     return(await FetchApi.DeleteAsync <ProductErrorMessage>("products/" + productID));
 }
        public static async Task <ServerResponse <Product, ProductErrorMessage> > GetProductByID(int productID)
        {
            var res = await FetchApi.GetAsync <Product, ProductErrorMessage>($"products/{productID}");

            return(res);
        }
        public static async Task <ServerResponse <List <Product>, ProductErrorMessage> > GetAllProducts()
        {
            var res = await FetchApi.GetAsync <List <Product>, ProductErrorMessage>("products");

            return(res);
        }
示例#13
0
 public static async Task <ServerResponse <object, ComboErrorMessage> > DeleteCombo(int comboID)
 {
     return(await FetchApi.DeleteAsync <ComboErrorMessage>("combos/" + comboID));
 }
示例#14
0
 public static async Task <ServerResponse <object, ComboErrorMessage> > UpdateCombo(int comboID, object combo)
 {
     return(await FetchApi.PutAsync <ComboErrorMessage>("combos/" + comboID, combo));
 }
示例#15
0
 public static async Task <ServerResponse <object, ComboErrorMessage> > CreateCombo(Combo combo)
 {
     return(await FetchApi.PostAsync <ComboErrorMessage>("combos", combo));
 }
        public static async Task <ServerResponse <Catalog, CatalogErrorMessage> > GetCatalogByID(int catalogID)
        {
            var res = await FetchApi.GetAsync <Catalog, CatalogErrorMessage>($"catalogs/{catalogID}");

            return(res);
        }
 public static async Task <ServerResponse <object, CatalogErrorMessage> > CreateCatalog(Catalog catalog)
 {
     return(await FetchApi.PostAsync <CatalogErrorMessage>("catalogs", catalog));
 }
示例#18
0
        public static async Task <ServerResponse <User, UserErrorMessage> > GetUserByID(int userID)
        {
            var res = await FetchApi.GetAsync <User, UserErrorMessage>($"user/{userID}");

            return(res);
        }
 public static async Task <ServerResponse <object, CatalogErrorMessage> > DeleteCatalog(int catalogID)
 {
     return(await FetchApi.DeleteAsync <CatalogErrorMessage>("catalogs/" + catalogID));
 }
示例#20
0
 public static async Task <ServerResponse <object, UserErrorMessage> > CreateUser(User user)
 {
     return(await FetchApi.PostAsync <UserErrorMessage>("user", user));
 }
        public static async Task <ServerResponse <Order, OrderErrorMessage> > GetOrderByID(int orderID)
        {
            var res = await FetchApi.GetAsync <Order, OrderErrorMessage>($"orders/{orderID}");

            return(res);
        }
示例#22
0
 public static async Task <ServerResponse <object, UserErrorMessage> > UpdateUser(int userID, User user)
 {
     return(await FetchApi.PutAsync <UserErrorMessage>("user/" + userID, user));
 }
 public static async Task <ServerResponse <object, OrderErrorMessage> > UpdateOrder(int orderID, Order order)
 {
     return(await FetchApi.PutAsync <OrderErrorMessage>($"orders/{orderID}", order));
 }
示例#24
0
 public static async Task <ServerResponse <object, UserErrorMessage> > DeleteUser(int userID)
 {
     return(await FetchApi.DeleteAsync <UserErrorMessage>("user/" + userID));
 }
 public static async Task <ServerResponse <object, OrderErrorMessage> > RefuseOrder(int orderID, ConfirmOrderDTO data)
 {
     return(await FetchApi.PostAsync <OrderErrorMessage>($"orders/{orderID}/refuse", data));
 }
示例#26
0
        public static async Task <ServerResponse <List <Combo>, ComboErrorMessage> > GetAllCombos()
        {
            var res = await FetchApi.GetAsync <List <Combo>, ComboErrorMessage>("combos");

            return(res);
        }