コード例 #1
0
        // GET: Exam
        public ActionResult Index()
        {
            var categorylist = _categoryService.GetAll();

            ViewBag.CategoryId = new SelectList(categorylist.Where(i => i.Status == true), "Id", "Name", selectedValue: "Id");

            var examtypelist = _examTypeService.GetAll();

            ViewBag.ExamTypeId = new SelectList(examtypelist.Where(i => i.Status == true), "Id", "Name");


            return(View());
        }
コード例 #2
0
        public async Task <ActionResult> Create(ExamResource examresource)
        {
            if (ModelState.IsValid)
            {
                var exam = Mapper.Map <ExamResource, Exam>(examresource);
                exam.CreatedDate = DateTime.Now;
                exam.UpdatedDate = DateTime.Now;
                var userId = System.Web.HttpContext.Current.User.Identity.GetUserId();
                exam.UserId = userId;

                await _examservice.AddAsync(exam);

                _examservice.UnitOfWorkSaveChanges();

                return(RedirectToAction("Index"));
            }
            var examtype    = _examTypeService.GetAll();
            var subcategory = _subCategoryService.GetAll();

            ViewBag.ExamtypeId    = new SelectList(examtype.Where(i => i.Status == true), "Id", "Name", examresource.Examtypeid);
            ViewBag.SubcategoryId = new SelectList(subcategory.Where(i => i.Status == true), "Id", "Name", examresource.SubcategoryId);
            return(View(examresource));
        }