Example #1
0
        public static string ExportPrisonersInbox(SoftJailDbContext context, string prisonersNames)
        {
            var names = prisonersNames.Split(',', StringSplitOptions.RemoveEmptyEntries);

            var result = context.Prisoners
                         .Include(x => x.Mails)
                         .Where(x => names.Contains(x.FullName))
                         .ProjectTo <PrisonerViewModel>()
                         .OrderBy(x => x.Name)
                         .ThenBy(x => x.Id)
                         .ToList();

            var xml = XmlConverter.Serialize(result, "Prisoners");

            return(xml);
        }
Example #2
0
        public static string ExportPrisonersInbox(SoftJailDbContext context, string prisonersNames)
        {
            var names = prisonersNames.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();

            var prisoners = context.Prisoners.Where(x => names.Contains(x.FullName))
                            .Select(p => new PrisonersExportXmlmodel
            {
                Id   = p.Id,
                Name = p.FullName,
                IncarcerationDate = p.IncarcerationDate.ToString("yyyy-MM-dd"),
                EncryptedMessages = p.Mails.Select(m => new MessagesExportXmlModel
                {
                    Description = string.Join("", m.Description.Reverse())
                }).ToArray()
            })
                            .OrderBy(x => x.Name)
                            .ThenBy(x => x.Id)
                            .ToList();

            var xml = XmlConverter.Serialize(prisoners, "Prisoners");

            return(xml);
        }
        public static string ExportPrisonersInbox(SoftJailDbContext context, string prisonersNames)
        {
            List <string> prisonerNames = prisonersNames.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
            var           prisonersMail = context.Prisoners
                                          .Where(x => prisonerNames.Contains(x.FullName))
                                          .Select(x => new ExportPrisonerDto()
            {
                Id                = x.Id,
                FullName          = x.FullName,
                IncarcerationDate = x.IncarcerationDate.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture),
                EncryptedMessages = x.Mails.Select(y => new EncryptedMessagesDto()
                {
                    Description = MailDescriptionReverse(y.Description)
                })
                                    .ToArray(),
            })
                                          .OrderBy(x => x.FullName)
                                          .ThenBy(x => x.Id)
                                          .ToArray();

            var serializedEProject = XmlConverter.Serialize(prisonersMail, "Prisoners");

            return(serializedEProject);
        }
        public static string ExportPrisonersInbox(SoftJailDbContext context, string prisonersNames)
        {
            var names     = prisonersNames.Split(',', StringSplitOptions.RemoveEmptyEntries);
            var prisoners = context.Prisoners
                            .ToList()
                            .Where(x => names.Contains(x.FullName))
                            .Select(x => new PrisonerXmlOutputModel
            {
                Id   = x.Id,
                Name = x.FullName,
                IncarcerationDate = x.IncarcerationDate.ToString("yyyy-MM-dd"),
                EncryptedMessages = x.Mails.Select(m => new EncryptedMailsModel()
                {
                    Description = Reverse(m.Description),
                }).ToArray(),
            })
                            .OrderBy(x => x.Name)
                            .ThenBy(x => x.IncarcerationDate)
                            .ToList();

            var result = XmlConverter.Serialize(prisoners, "Prisoners");

            return(result);
        }
Example #5
0
        public static string ExportPrisonersInbox(SoftJailDbContext context, string prisonersNames)
        {
            var prisoners = context.Prisoners
                            .Where(p => prisonersNames.Contains(p.FullName))
                            .Select(x => new ExPrisonerMailDto
            {
                Id   = x.Id,
                Name = x.FullName,
                IncarcerationDate = x.IncarcerationDate.ToString("yyyy-MM-dd"),
                Messages          = x.Mails.Select(x => new ExMessageDto
                {
                    Description = String.Join("", x.Description.Reverse())
                })
                                    .ToArray()
            })
                            .OrderBy(x => x.Name)
                            .ThenBy(x => x.Id)
                            .ToArray();

            var root   = "Prisoners";
            var result = XmlConverter.Serialize(prisoners, root);

            return(result);
        }