Beispiel #1
0
        public ITSupporterOfflineFirebaseViewModel RenderDataForITSupporterOffline(int itSupporterId)
        {
            var accountService     = new AccountService();
            var itSupporterService = new ITSupporterService();
            var itSupporter        = itSupporterService.GetAll().SingleOrDefault(p => p.ITSupporterId == itSupporterId);
            var account            = accountService.GetAll().SingleOrDefault(a => a.AccountId == itSupporter.AccountId);

            var itSupporterOfflineFirebaseViewModel = new ITSupporterOfflineFirebaseViewModel()
            {
                ITSupporterName = itSupporter.ITSupporterName,
                ITSupporterId   = itSupporter.ITSupporterId,
                isOnline        = itSupporter.IsOnline ?? false,
                AccountId       = itSupporter.AccountId,
                Username        = account.Username
            };


            return(itSupporterOfflineFirebaseViewModel);
        }
Beispiel #2
0
        public ITSupporterReceiveFirebaseViewModel RenderDataForITSupporterReceive(int itSupporterId, int requestId)
        {
            var requestService     = new RequestService();
            var itSupporterService = new ITSupporterService();
            var agencyService      = new AgencyService();
            var ticketService      = new TicketService();
            var accountService     = new AccountService();
            var deviceService      = new DeviceService();
            var deviceTypeService  = new DeviceTypeService();

            var request     = requestService.GetAll().SingleOrDefault(p => p.RequestId == requestId);
            var agency      = agencyService.GetAll().SingleOrDefault(p => p.AgencyId == request.AgencyId);
            var ticket      = ticketService.GetAll().Where(p => p.RequestId == request.RequestId);
            var itSupporter = itSupporterService.GetAll().SingleOrDefault(p => p.ITSupporterId == itSupporterId);
            var account     = accountService.GetAll().SingleOrDefault(a => a.AccountId == itSupporter.AccountId);
            var itSupporterReceiveFirebaseViewModel = new ITSupporterReceiveFirebaseViewModel()
            {
                AgencyName      = agency.AgencyName,
                AgencyAddress   = agency.Address,
                RequestId       = request.RequestId,
                RequestName     = request.RequestName,
                NumberOfTicket  = ticket.Count(),
                ITSupporterId   = itSupporter.ITSupporterId,
                ITSupporterName = itSupporter.ITSupporterName,
                AccountId       = itSupporter.AccountId,
                Username        = account.Username
            };
            StringBuilder ticketInfo = new StringBuilder();

            foreach (var item in ticket)
            {
                var device = deviceService.GetAll().SingleOrDefault(d => d.DeviceId == item.DeviceId);
                ticketInfo.AppendLine($"Thiết bị: {deviceTypeService.GetAll().SingleOrDefault(dt => dt.DeviceTypeId == device.DeviceTypeId).DeviceTypeName} - {deviceService.GetAll().SingleOrDefault(d => d.DeviceId == item.DeviceId).DeviceName}");
            }
            itSupporterReceiveFirebaseViewModel.TicketsInfo = ticketInfo.ToString();
            itSupporterReceiveFirebaseViewModel.DateSend    = DateTime.UtcNow.AddHours(7).ToString("HH:mm:ss");
            return(itSupporterReceiveFirebaseViewModel);
        }