public async Task <ActionResult <bool> > PostAddTicketingChat(CreatTicketViewModel model)
        {
            string userId = User.Claims.First(c => c.Type == "seemsys").Value;
            Person s      = await _context.People.SingleOrDefaultAsync(y => y.Role1 == 2 && y.Role2 == 1 && y.Role3 == 1 && y.Role4 == 1);

            Ticket ticket = new Ticket()
            {
                Service_ID        = model.Services_ID,
                Title             = model.Title,
                PersonNational_ID = userId,
                DateOfCreation    = DateTime.Now.ToString(),
                Active            = true,
                Closure           = DateTime.Now.ToString(),
                Status            = model.Status,
                Resiver           = s.PersonNational_ID
            };
            TicketingChat ticketingChat = new TicketingChat()
            {
                Ticket_ID         = await _ticketService.AddTicket(ticket),
                Comment           = model.Comment,
                CommentTime       = DateTime.Now.ToString(),
                PersonNational_ID = userId,
                Confidential      = false,
                Resiver           = s.PersonNational_ID,
                Sender            = userId,
            };

            return(await _ticketService.AddTicketingChat(ticketingChat));
        }
        //ثبت پیام های ارسالی بین کاربران با سطوح مختلف در جدول
        public async Task <bool> AddComment(TicketingChat ticketingChat)
        {
            await _context.TicketingChats.AddAsync(ticketingChat);

            await _context.SaveChangesAsync();

            return(true);
        }
Beispiel #3
0
        public async Task <ActionResult <bool> > PostAddTicketingChat(ChatTicketingViewModel model)
        {
            bool   t;
            string u;
            string userId = User.Claims.First(c => c.Type == "seemsys").Value;

            if (model.Resiver == "" || model.Resiver == null)
            {
                Person s = await _context.People.SingleOrDefaultAsync(y => y.Role1 == 2 && y.Role2 == 1 && y.Role3 == 1 && y.Role4 == 1);

                u = s.PersonNational_ID;
            }
            else
            {
                u = model.Resiver;
            }
            if (model.Conf == 1)
            {
                t = true;
            }
            else
            {
                t = false;
            }
            TicketingChat ticketingChat = new TicketingChat()
            {
                Ticket_ID         = model.Ticket_ID,
                Comment           = model.Comment,
                CommentTime       = DateTime.Now.ToString(),
                PersonNational_ID = userId,
                Sender            = userId,
                Resiver           = u,
                Confidential      = t
            };

            return(await _ticketChat.AddComment(ticketingChat));
        }