public IActionResult Post([FromBody] Ticket ticket) { if (ticket == null) { return(BadRequest()); } _repo.Create(ticket); return(Ok()); }
public ActionResult Create( [Bind(Include = "Name, PhoneNumber, Description")] Ticket ticket) { ticket.CreatedAt = DateTime.UtcNow; if (ModelState.IsValid) { _repository.Create(ticket); ViewBag.Success = "Your ticket was submitted! An agent will call you soon."; ModelState.Clear(); return(View("Index")); } return(View("Index")); }
public async Task <ActionResult> Create(Ticket ticket) { ViewBag.Departments = new SelectList(await this.departmentsRepository.GetAll(), "DepartmentId", "DepartmentName"); if (ModelState.IsValid) { ticket.TicketHash = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); var ticketStatus = await ticketsStatusRepository.GetById(1); ticket.TicketStatusId = ticketStatus.TicketStatusId; await ticketsRepository.Create(ticket); ticketsMailer.Send(Constants_files.Constants.MAIL_HEADER, string.Format("{0} Ticket id: {1}. Ticket url: {2}", Constants_files.Constants.MAIL_SUBJECT, ticket.TicketHash, Url.Action("GetTicket", "Tickets", new { id = ticket.TicketId }, Request.Url.Scheme)), ticket.CustomerEmail); return(Redirect("/")); } return(View(ticket)); }
public Ticket Create(Ticket ticket) { return(repository.Create(ticket)); }