Ejemplo n.º 1
0
        public async Task <int> CreateProduct(PRODUCT product)
        {
            try
            {
                var prod = new PRODUCT
                {
                    ProductName        = product.ProductName,
                    ProductPrice       = product.ProductPrice,
                    ProductDescription = product.ProductDescription,
                    PromotionPrice     = product.PromotionPrice,
                    ProductStock       = product.ProductStock,
                    ProductURL         = SlugGenerator.SlugGenerator.GenerateSlug(product.ProductName),
                    ProductImage       = product.ProductImage,
                    ProductStatus      = product.ProductStatus,
                    BrandID            = product.BrandID,
                    CreatedDate        = DateTime.Now
                };

                db.PRODUCTs.Add(prod);
                await db.SaveChangesAsync();

                return(prod.ProductID);
            }
            catch
            {
                return(0);
            }
        }
        public async Task <int> CreateOrder(ORDER order)
        {
            try
            {
                db.ORDERs.Add(order);
                await db.SaveChangesAsync();

                return(order.OrderID);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        public async Task <bool> DeleteCustomer(int ID)
        {
            try
            {
                var cus = await db.CUSTOMERs.Where(x => x.CustomerID == ID).SingleOrDefaultAsync();

                db.CUSTOMERs.Remove(cus);
                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public async Task <int> AddOrderCustomer(int CustomerID, string name, string address, string phone, decimal total)
        {
            var order = new ORDER
            {
                CustomerID      = CustomerID,
                CustomerName    = name,
                CustomerAddress = address,
                CustomerPhone   = phone,
                OrderStatusID   = 1,
                Total           = total,
                OrderDate       = DateTime.Now
            };

            db.ORDERs.Add(order);
            await db.SaveChangesAsync();

            return(order.OrderID);
        }
Ejemplo n.º 5
0
        public async Task <int> CreateBrand(BRAND brand)
        {
            try
            {
                BRAND item = new BRAND()
                {
                    BrandName   = brand.BrandName,
                    BrandURL    = SlugGenerator.SlugGenerator.GenerateSlug(brand.BrandName),
                    CreatedDate = DateTime.Now
                };
                db.BRANDs.Add(item);
                await db.SaveChangesAsync();

                return(item.BrandID);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 6
0
        public async Task <int> CreateConfiguration(CONFIGURATION model)
        {
            try
            {
                if (db.PRODUCTs.FindAsync(model.ProductID) == null)
                {
                    return(0);
                }

                db.CONFIGURATIONs.Add(model);
                await db.SaveChangesAsync();

                return(model.ConfigID);
            }
            catch
            {
                return(0);
            }
        }
        public async Task <int> AddOrderDetail(int OrderID, int ProductID, int Quanity)
        {
            try {
                var order = new ORDERDETAIL()
                {
                    OrderID   = OrderID,
                    ProductID = ProductID,
                    Quantity  = Quanity
                };
                db.ORDERDETAILs.Add(order);
                await db.SaveChangesAsync();

                return(order.DetailID);
            }
            catch
            {
                return(0);
            }
        }