Exemple #1
0
        public string ConverMessageJsonForITSupporterReceiveFirebaseViewModel(ITSupporterReceiveFirebaseViewModel data, Notification noti)
        {
            Dictionary <string, object> androidMessageDic = new Dictionary <string, object>();

            androidMessageDic.Add("to", $"/topics/{data.ITSupporterId}");
            androidMessageDic.Add("data", data);
            androidMessageDic.Add("notification", noti);

            return(JsonConvert.SerializeObject(androidMessageDic));
        }
Exemple #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);
        }