Пример #1
0
        public static async Task <models.Work> Item(Guid?id)
        {
            if (!id.HasValue)
            {
                return(null);
            }
            Tables.dbo.Work item = await dbRead.Work.Item(id.Value);

            if (item == null)
            {
                return(null);
            }
            var output = new models.Work
            {
                Id          = item.Id,
                Cover       = await Image.Item(item.CoverId),
                Title       = item.Title,
                Authors     = item.Authors,
                Href        = item.Href,
                DateCreated = item.DateCreated,
                Display     = item.Display
            };

            return(output);
        }
Пример #2
0
 private static List <Task <models.Work> > Complete(IEnumerable <Tables.dbo.Work> inputList)
 {
     return(inputList.Select(async n => new models.Work
     {
         Id = n.Id,
         Cover = await Image.Item(n.CoverId),
         Title = n.Title,
         Authors = n.Authors,
         Href = n.Href,
         DateCreated = n.DateCreated,
         Display = n.Display
     }).ToList());
 }
        private static async Task <models.Testimonial> Item(Tables.dbo.Testimonial testimonial)
        {
            try
            {
                models.Image portrait = await Image.Item(testimonial.PortraitImageId);

                models.Work work = await Work.Item(testimonial.WorkId);

                if ((portrait == null) && (work?.Cover?.Id != null))
                {
                    portrait = await Image.Item(work.Cover.Id);
                }
                List <Tables.Localization.Testimonial> localizedList = await dbLocalizedRead.List(testimonial.Id);

                var output = new models.Testimonial
                {
                    Id           = testimonial.Id,
                    Work         = work,
                    Portrait     = portrait,
                    Name         = testimonial.Name,
                    EmailAddress = testimonial.EmailAddress,
                    DateCreated  = testimonial.DateCreated,
                    Approved     = testimonial.Approved,
                    Entries      = localizedList.Select(n => new Models.ProfessionalTranslator.Net.Localized.Testimonial
                    {
                        Lcid = n.Lcid,
                        Html = n.Html.Trim()
                    }).ToList()
                };
                return(output);
            }
            catch (System.Exception ex)
            {
                Console.Write(ex.Message);
                return(null);
            }
        }