Пример #1
0
        public static Task <PrioritiseTransportsViewModel> LoadAsync(EmailServiceContext ctx, Guid id)
        {
            PrioritiseTransportsViewModel model = null;

            var app = ctx.Applications
                      .Include(a => a.Transports)
                      .ThenInclude(a => a.Transport)
                      .FirstOrDefault(a => a.Id == id);

            if (app != null)
            {
                model = new PrioritiseTransportsViewModel
                {
                    ApplicationId   = app.Id,
                    ApplicationName = app.Name
                };

                model.Transports = app.Transports.Select(t => new TransportPriorityViewModel
                {
                    TransportId = t.TransportId,
                    Priority    = t.Priority,
                    Name        = t.Transport.Name
                }).ToList();
            }

            return(Task.FromResult(model));
        }