예제 #1
0
        public async Task <IActionResult> AnswerTicket(int id)
        {
            var ticket = await service.FindTicket(id);

            if (ticket == null)
            {
                return(NotFound());
            }
            if (ticket.IsAnswered)
            {
                return(RedirectToAction("DisplayAllSendTickets"));
            }

            var answer = new AnswerTicketBindingModel();

            answer.IdSendTicket = ticket.Id;
            answer.Title        = ticket.Title;
            if (ticket.AgentId != null)
            {
                var AgentUsername = await service.FindUserNameById(ticket.AgentId);

                answer.AgentId = AgentUsername.UserName;
            }
            else
            {
                return(RedirectToAction("DisplayAllSendTickets"));
            }
            var AuthorUsername = await service.FindUserNameById(ticket.AuthorId);

            answer.AuthorId = AuthorUsername.UserName;
            return(View(answer));
        }
예제 #2
0
        public async Task <IActionResult> AnswerTicket(AnswerTicketBindingModel model)
        {
            if (ModelState.IsValid)
            {
                var AgentId = await service.FindUserIdByName(model.AgentId);

                model.AgentId = AgentId.Id;
                var AuthorId = await service.FindUserIdByName(model.AuthorId);

                model.AuthorId = AuthorId.Id;

                await service.AnswerTicket(model);

                return(RedirectToAction("DisplayAllSendTickets"));
            }
            return(View());
        }
예제 #3
0
        public async Task <IActionResult> AnswerTicket(AnswerTicketBindingModel model)
        {
            if (ModelState.IsValid)
            {
                var AgentId = await service.FindUserIdByName(model.AgentId);

                model.AgentId = AgentId.Id;
                var AuthorId = await service.FindUserIdByName(model.AuthorId);

                model.AuthorId = AuthorId.Id;

                await service.AnswerTicket(model);

                return(RedirectToAction("MyAnswerTickets", "Ticket", new { id = User.Identity.Name, area = "Agent" }));
            }
            return(View());
        }
예제 #4
0
        public async Task AnswerTicket(AnswerTicketBindingModel model)
        {
            var sendTicked = await FindTicket(model.IdSendTicket);

            var answerTicket = new Ticket();

            answerTicket.Title      = model.Title;
            answerTicket.AgentId    = model.AgentId;
            answerTicket.AuthorId   = model.AuthorId;
            answerTicket.Descripton = model.Description;
            answerTicket.SendOn     = model.SendOn;
            answerTicket.TicketId   = model.IdSendTicket;

            sendTicked.IsAnswered    = true;
            sendTicked.ToReplyTicket = answerTicket;

            dbContext.Tickets.Update(sendTicked);
            await dbContext.Tickets.AddAsync(answerTicket);

            await dbContext.SaveChangesAsync();
        }