Exemple #1
0
        public async Task <int> Create(Tbl_userRequest tbl_userRequest)
        {
            var tbl_user = new tbl_user()
            {
                name    = tbl_userRequest.name,
                address = tbl_userRequest.address,
                phone   = tbl_userRequest.phone,
            };

            _context.tbl_users.Add(tbl_user);

            return(await _context.SaveChangesAsync());
        }
Exemple #2
0
        public async Task <int> Create(Tbl_orderRequest tbl_orderRequest)
        {
            var tbl_order = new tbl_order()
            {
                fee      = tbl_orderRequest.fee,
                discount = tbl_orderRequest.discount,
                total    = tbl_orderRequest.total
            };

            _context.tbl_orders.Add(tbl_order);

            return(await _context.SaveChangesAsync());
        }
Exemple #3
0
        public async Task <int> Create(Tbl_productRequest tbl_productRequest)
        {
            var tbl_product = new tbl_product()
            {
                name     = tbl_productRequest.name,
                price    = tbl_productRequest.price,
                image    = tbl_productRequest.image,
                category = tbl_productRequest.category
            };

            _context.tbl_products.Add(tbl_product);

            return(await _context.SaveChangesAsync());
        }
Exemple #4
0
        public async Task <int> Create(Tbl_paymentRequest tbl_paymentRequest)
        {
            int maxIdOrder  = _context.tbl_orders.Max(u => u.id);
            var tbl_payment = new tbl_payment()
            {
                receive = tbl_paymentRequest.receive,
                refund  = tbl_paymentRequest.refund,
                type    = tbl_paymentRequest.type,
                idorder = maxIdOrder
            };

            _context.tbl_payments.Add(tbl_payment);

            return(await _context.SaveChangesAsync());
        }
Exemple #5
0
        public async Task <int> Create(Tbl_itemRequest tbl_itemRequest)
        {
            int maxId    = _context.tbl_orders.Max(u => u.id);
            var tbl_item = new tbl_item()
            {
                idproduct = tbl_itemRequest.idproduct,
                discount  = tbl_itemRequest.discount,
                quanlity  = tbl_itemRequest.quanlity,
                price     = tbl_itemRequest.price,
                idorder   = maxId
            };

            _context.tbl_items.Add(tbl_item);

            return(await _context.SaveChangesAsync());
        }
        public async Task <int> Create(Tbl_billRequest tbl_billRequest)
        {
            int maxIdOrder   = _context.tbl_orders.Max(u => u.id);
            int maxIdPayment = _context.tbl_payments.Max(u => u.id);
            var tbl_bill     = new tbl_bill()
            {
                create_at = DateTime.Now,
                iduser    = tbl_billRequest.iduser,
                idpayment = maxIdPayment,
                idorder   = maxIdOrder,
            };

            _context.tbl_bills.Add(tbl_bill);

            return(await _context.SaveChangesAsync());
        }