Пример #1
0
        // GET: Admin/CourseSubscription/Create
        public async Task <ActionResult> Create()
        {
            var model = new CourseSubscriptionModel
            {
                Subscriptions = await db.Subscriptions.ToListAsync(),
                courses       = await db.Courses.ToListAsync()
            };

            return(View(model));
        }
Пример #2
0
        public static async Task <CourseSubscriptionModel> Convert(
            this CourseSubscription courseSubscription,
            ApplicationDbContext db, bool addListData = true)
        {
            var model = new CourseSubscriptionModel
            {
                SubscriptionId    = courseSubscription.SubscriptionId,
                CourseId          = courseSubscription.CourseId,
                Subscriptions     = addListData ? await db.Subscriptions.ToListAsync() : null,
                courses           = addListData ? await db.Courses.ToListAsync() : null,
                SubscriptionTitle = (await db.Subscriptions.FirstOrDefaultAsync(s =>
                                                                                s.Id.Equals(courseSubscription.SubscriptionId))).Title,
                CourseTitle = (await db.Courses.FirstOrDefaultAsync(p =>
                                                                    p.Id.Equals(courseSubscription.CourseId))).Title
            };

            return(model);
        }