Example #1
0
        public IActionResult AddTicket([FromBody] Category c)
        {
            if (c == null ||
                _repositiry.GetCategories().FirstOrDefault(x => x.Id == c.Id) == null)
            {
                return(BadRequest());
            }

            var t = new Ticket()
            {
                Id         = _repositiry.GetLastTicketId() + 1,
                Category   = c.Id,
                CreateDate = DateTime.UtcNow,
                IsClosed   = false
            };

            _repositiry.AddTicket(t);

            return(CreatedAtRoute(new { id = t.Id }, t));
        }