Exemple #1
0
        //public async Task<ActionResult> DeleteProgram(int id)
        //{
        //    if(id == 0)
        //    {
        //        return View("ProgramList");
        //    }

        //    var pList = await _eClassAppService.Delete(id);
        //    var model = new ProgramListViewModel(pList.Items);
        //    return View("ProgramList", model);
        //}

        public async Task <ActionResult> UpdateProgram(int id)
        {
            var pList = _eClassAppService.GetProgramById(id);

            var userTypeSelectListItems = (await _eClassAppService.GetUserTypeDDLItems()).Items
                                          .Select(p => p.ToSelectListItem())
                                          .ToList();

            userTypeSelectListItems.Insert(0, new SelectListItem {
                Value = string.Empty, Text = L("DEFAULTSELECT"), Selected = true
            });

            var programTypeSelectListItems = (await _eClassAppService.GetProgramTypeDDLItems()).Items
                                             .Select(p => p.ToSelectListItem())
                                             .ToList();

            programTypeSelectListItems.Insert(0, new SelectListItem {
                Value = string.Empty, Text = L("DEFAULTSELECT"), Selected = true
            });

            CreateProgramViewModel cpVM = new CreateProgramViewModel(userTypeSelectListItems, programTypeSelectListItems);

            cpVM.ProgramId       = pList.Id;
            cpVM.UniqueId        = pList.UniqueId;
            cpVM.Name            = pList.Name;
            cpVM.Description     = pList.Description;
            cpVM.Status          = pList.Status;
            cpVM.ProgramLastDate = pList.ProgramLastDate;
            cpVM.UserTypeId      = pList.UserTypeId;
            cpVM.ProgramTypeId   = pList.ProgramTypeId;

            return(View("UpdateProgram", cpVM));
        }
        public async Task <PartialViewResult> GetContentDetail(int programId)
        {
            string viewName            = "PreviewDetail";
            GetCategoryListInput input = new GetCategoryListInput();

            input.ProgramListId = programId;

            var output = await _eClassAppService.GetCategoryListByProgramId(input);

            var program = _eClassAppService.GetProgramById(input.ProgramListId);

            if (program != null)
            {
                ViewBag.UniqueId    = program.UniqueId;
                ViewBag.Name        = program.Name;
                ViewBag.Description = program.Description;

                if (program.ProgramTypeId == 1)
                {
                    ViewBag.ProgramType = "Training";
                }
                else if (program.ProgramTypeId == 2)
                {
                    ViewBag.ProgramType = "Survey";
                }
            }

            if (program.ProgramTypeId == 1)
            {
                viewName = "PreviewTraining";
            }
            else if (program.ProgramTypeId == 2)
            {
                viewName = "PreviewDetail";
            }

            List <CBTContentDto> cbtContentList = new List <CBTContentDto>();

            foreach (var cat in output.Items)
            {
                var contentByCategoryId = await _eClassAppService.GetCBTContentByCategoryId(cat.Id);

                cbtContentList.AddRange(contentByCategoryId);
            }
            cbtContentList = cbtContentList.ToList();

            var programSelectListItems = (await _eClassAppService.GeProgramDDLItems()).Items
                                         .Select(p => p.ToSelectListItem())
                                         .ToList();

            programSelectListItems.Insert(0, new SelectListItem {
                Value = string.Empty, Text = L("DEFAULTSELECT"), Selected = true
            });

            CategoryListViewModel clVM = new CategoryListViewModel(output.Items);

            clVM.CBTContentLists = cbtContentList;
            clVM.ProgramList     = programSelectListItems;
            clVM.ProgramListId   = programId;

            return(PartialView(viewName, clVM));
        }