Ejemplo n.º 1
0
        public ActionResult Create(ExamEntryForView model)
        {
            var exam = Mapper.Map <Exam>(model);

            var examall = _examEntryBll.GetAll();
            var Isave   = false;

            for (int i = 0; i < examall.Count; i++)
            {
                if ((model.ExamCode == examall[i].ExamCode))

                {
                    Isave = true;
                }
            }

            if (Isave == true)
            {
                ViewBag.EMsg = "Duplicate";
            }
            else
            {
                bool isAdded = _examEntryBll.Add(exam);
                if (isAdded)
                {
                    ViewBag.SMsg = "Save Is Successfully";
                    model        = new ExamEntryForView();
                }
                else
                {
                    ViewBag.EMsg = "Save Is UnSuccessfully";
                }
            }


            model.OrganizationSelectListItems = _organizationBll.GetAll()
                                                .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            });
            model.CourseSelectListItems = _courseBll.GetAll()
                                          .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            });
            model.ExamTypeList = _examTypeBll.GetAll()
                                 .Select(c => new SelectListItem()
            {
                Value = c.Examtype.ToString(),
                Text  = c.ExamtypeName
            }).ToList();

            return(View(model));
        }
Ejemplo n.º 2
0
        public PartialViewResult CreateExam(ExamEntryForView ExmEntryFV)
        {
            var exam = Mapper.Map <Exam>(ExmEntryFV);

            var dataList = _examBll.GetAll().Where(e => e.CourseId == ExmEntryFV.CourseId && e.ExamCode == ExmEntryFV.ExamCode);

            if (dataList.Count() > 0)
            {
                ViewBag.EMsg = "data is already here";
            }
            else
            {
                bool isSave = _examBll.Add(exam);
                if (isSave)
                {
                    ViewBag.SMsg = "Saved  Successfully";
                    ExmEntryFV   = new ExamEntryForView();
                }
                else
                {
                    ViewBag.EMsg = "Failed..";
                }
            }


            //ViewBag.CourseId = _courseBll.GetAll()
            //    .Select(c => new SelectListItem()
            //    {
            //        Value = c.Id.ToString(),
            //        Text = c.Name
            //    }).ToList();
            ViewBag.Examtype = _examTypeBll.GetAll()
                               .Select(c => new SelectListItem()
            {
                Value = c.Examtype.ToString(),
                Text  = c.ExamtypeName
            }).ToList();
            List <Organization> orglist = _organizationBll.GetAll();

            ViewBag.OrgList = new SelectList(orglist, "Id", "Name", ExmEntryFV.OrganizationId);
            List <Course> list = _courseBll.GetAll().Where(e => e.Organizationid == ExmEntryFV.OrganizationId).ToList();;

            ViewBag.CourseList = new SelectList(list, "Id", "Name", ExmEntryFV.CourseId);
            return(PartialView("~/Views/Shared/Course/_CreateExam.cshtml", ExmEntryFV));
        }