コード例 #1
0
        public ActionResult <Ticket> Delete(int id)
        {
            var objTicket = context.ticket.FirstOrDefault(x => x.id == id);

            if (objTicket == null)
            {
                return(NotFound());
            }
            context.Remove(objTicket);
            context.SaveChanges();
            return(Ok());
        }
コード例 #2
0
        public bool RemoveById(int Id)
        {
            var dbTicket = _ticketDbContext.Tickets.FirstOrDefault(i => i.Id == Id);

            try
            {
                _ticketDbContext.Remove(dbTicket);
                _ticketDbContext.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }