示例#1
0
        // GET: Batch
        public ActionResult Index(int?classId)
        {
            ViewBag.ClassList = (from c in _classService.GetClasses()
                                 select new SelectListItem
            {
                Value = c.ClassId.ToString(),
                Text = c.Name
            }).ToList();

            ViewBag.ClassId = classId;
            var batches       = (classId == null) ? _batchService.GetAllBatches().ToList() : _batchService.GetBatches((int)classId).ToList();
            var viewModelList = AutoMapper.Mapper.Map <List <BatchProjection>, BatchViewModel[]>(batches);

            var roleUserId = User.Identity.GetUserId();
            var roles      = _aspNetRolesService.GetCurrentUserRole(roleUserId);

            ViewBag.userRole = roles;

            if (roles == "Admin")
            {
                ViewBag.userId = 0;
            }
            else
            {
                ViewBag.userId = "";
            }


            return(View(viewModelList));
        }
        public ActionResult GetBatchesByClassId(string selectedClasses, string selectedBranch)
        {
            var classIds      = selectedClasses.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse);
            var batchesResult = _batchService.GetAllBatches();;
            var batches       = (batchesResult).ToList().Where(x => classIds.Contains(x.ClassId));

            var result = new
            {
                batches = batches
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult BranchClassBatchShow(int id)
        {
            var studentTimetable = _studentTimetableService.GetStudentTimetableById(id);

            ViewBag.fileName = studentTimetable.FileName;
            if (studentTimetable == null)
            {
                _logger.Warn(string.Format("Student Time Table does not Exists {0}.", id));
                Warning("Student Time Table does not Exists.");
                return(RedirectToAction("Index"));
            }
            var viewModel = AutoMapper.Mapper.Map <StudentTimetableProjection, StudentTimetableEditViewModel>(studentTimetable);

            var           commaseperatedBranchList = studentTimetable.SelectedBranches ?? string.Empty;
            var           branchIds    = commaseperatedBranchList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse);
            var           branchResult = _branchService.GetAllBranches();
            var           branches     = (branchResult).Where(x => branchIds.Contains(x.BranchId)).ToList();
            List <string> BranchList   = new List <string>();

            BranchList = branches.Select(x => x.Name).ToList();
            var Branchlist = string.Join(",", BranchList);

            viewModel.SelectedBranches = Branchlist;

            var           commaseperatedClassList = studentTimetable.SelectedClasses ?? string.Empty;
            var           ClassIds    = commaseperatedClassList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse);
            var           classResult = _classService.GetClasses();
            var           Classees    = (classResult).Where(x => ClassIds.Contains(x.ClassId)).ToList();
            List <string> ClassList   = new List <string>();

            ClassList = Classees.Select(x => x.Name).ToList();
            var Classlist = string.Join(",", ClassList);

            viewModel.SelectedClasses = Classlist;

            var           commaseperatedBatchList = studentTimetable.SelectedBatches ?? string.Empty;
            var           BatchIds    = commaseperatedBatchList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse);
            var           batchResult = _batchService.GetAllBatches();
            var           Batch       = (batchResult).Where(x => BatchIds.Contains(x.BatchId)).ToList();
            List <string> BatchList   = new List <string>();

            BatchList = Batch.Select(x => x.BatchName).ToList();
            var BatchesList = string.Join(",", BatchList);

            viewModel.SelectedBatches = BatchesList.TrimEnd(',');
            var description = viewModel.Description.Replace("<br />", "\r\n");

            viewModel.Description = description;
            return(View(viewModel));
        }
 public IEnumerable <Batch> GetAllBatches()
 {
     return(_batchService.GetAllBatches());
 }
示例#5
0
        public HttpResponseMessage Get()
        {
            var batches = _batchService.GetAllBatches();

            return(Request.CreateResponse(HttpStatusCode.OK, batches));
        }