Beispiel #1
0
        public ActionResult Transfer(CurriculumTransferModel model)
        {
            var sourceCur = Db.Curricula.SingleOrDefault(x => x.Id == model.Curriculum.Id);
            var targetCur = Db.Curricula.SingleOrDefault(x => x.Id == model.TargetCurrId);


            var allStudents = Db.Students.Where(x => x.Curriculum.Id == sourceCur.Id);

            foreach (var student in allStudents)
            {
                student.Curriculum = targetCur;
            }

            Db.SaveChanges();


            return(RedirectToAction("Students", new { id = sourceCur.Id }));
        }
        public ActionResult Transfer(Guid id)
        {
            var curriculum = Db.Curricula.SingleOrDefault(x => x.Id == id);
            var curricula  = Db.Curricula.Where(x => x.Organiser.Id == curriculum.Id && x.Id != curriculum.Id)
                             .OrderBy(f => f.ShortName);

            var model = new CurriculumTransferModel
            {
                Curriculum   = curriculum,
                TargetCurrId = curricula.First().Id
            };


            ViewBag.Curricula = curricula.Select(f => new SelectListItem
            {
                Text  = f.Name,
                Value = f.Id.ToString(),
            });

            return(View(model));
        }