public ActionResult <List <Tcoupon> > GetMyAllGiftCards(int customerId)
        {
            var customer = new Tcustomer();

            customer = _context.Tcustomer.Find(customerId);
            return(customer.Tcoupon.ToList());
        }
        public ActionResult <List <TsoOrder> > GetAllOrdersByCustomerId(int customerId)
        {
            var customer = new Tcustomer();

            customer = _context.Tcustomer.Find(customerId);
            return(customer.TsoOrder.ToList());
        }
        public async Task <IActionResult> PutTcustomer(short id, Tcustomer tcustomer)
        {
            if (id != tcustomer.TcustomerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #4
0
        public ActionResult SaveNewTicket(TicketCreateVM createModel)
        {
            try
            {
                using (var dbContext = new TicketCodeTestDBContext())
                {
                    var dbTicket = new Tticket();
                    var dbCustom = new Tcustomer();
                    var dbBill   = new Tbill();
                    dbCustom.Name       = createModel.custormername;
                    dbCustom.SaleMan    = createModel.saleman;
                    dbCustom.SaleCount  = createModel.salecount;
                    dbCustom.SaleAmount = createModel.saleamount;



                    dbContext.Tcustomer.Add(dbCustom);
                }


                StringBuilder sbr = new StringBuilder();
                DapperWrapper.Insert(sbr.ToString());
                return(Json(new { success = true, msg = "保存成功" }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    msg = ex.ToString()
                }));
            }
        }
        public ActionResult <List <TsoOrder> > GetAllOrdersByCustomerId(int customerId)
        {
            var customer = new Tcustomer();

            customer = _context.Tcustomer.Find(customerId);
            return(_context.TsoOrder.Where(item => item.CustomerId == customer.Id).ToList());
        }
        public async Task <ActionResult <Tcustomer> > PostTcustomer(Tcustomer tcustomer)
        {
            _context.Tcustomer.Add(tcustomer);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TcustomerExists(tcustomer.TcustomerId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTcustomer", new { id = tcustomer.TcustomerId }, tcustomer));
        }