Ejemplo n.º 1
0
        public ActionResult Delete(TeacherModel model)
        {
            CourseContext ctx = new CourseContext();
              ctx.Teachers.Remove(ctx.Teachers.FirstOrDefault(c => c.ID == model.ID));

              return View();
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            var ctx = new CourseContext();

              ctx.Semesters.Remove(ctx.Semesters.FirstOrDefault(c => c.ID == id));
              ctx.SaveChanges();
              return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<Semester, SemesterModel>();

              var ctx = new CourseContext();

              var result = memberMapper.Map<Semester, SemesterModel>(ctx.Semesters.FirstOrDefault(c => c.ID == id));

              return View(result);
        }
Ejemplo n.º 4
0
        //
        // GET: /Group/Delete/5
        public ActionResult Delete(int id)
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<Group, GroupModel>();

              var ctx = new CourseContext();

              var result = memberMapper.Map<Group, GroupModel>(ctx.Groups.FirstOrDefault(c => c.ID == id));

              return View(result);
        }
Ejemplo n.º 5
0
        public ActionResult Create(SemesterModel model)
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<SemesterModel, Semester>();

              var ctx = new CourseContext();

              ctx.Semesters.Add(memberMapper.Map<SemesterModel, Semester>(model));
              ctx.SaveChanges();

              return RedirectToAction("Index");
        }
Ejemplo n.º 6
0
        public ActionResult Edit(SemesterModel model)
        {
            CourseContext ctx = new CourseContext();
              var semester = ctx.Semesters.FirstOrDefault(c => c.ID == model.ID);

              semester.Name = model.Name;
              semester.StartDate = model.StartDate;
              semester.EndDate = model.EndDate;

              ctx.SaveChanges();

              return RedirectToAction("Index");
        }
Ejemplo n.º 7
0
        public ActionResult Details(int id)
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<Teacher, TeacherModel>(source => new TeacherModel()
              {
            RoomNr = source.RoomNumber,
            SchoolPhone = source.Phone,
            Identifier = source.IDNumber
              });

              var ctx = new CourseContext();

              var result = memberMapper.Map<Teacher, TeacherModel>(ctx.Teachers.FirstOrDefault(c => c.ID == id));
              return View(result);
        }
Ejemplo n.º 8
0
        public ActionResult Add(TeacherModel model)
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<TeacherModel, Teacher>(source =>
            new Teacher()
            {
              Phone = source.SchoolPhone,
              IDNumber = source.Identifier,
              RoomNumber = source.RoomNr
            });

              CourseContext ctx = new CourseContext();
              ctx.Teachers.Add(memberMapper.Map<Teacher>(model));
              ctx.SaveChanges();

              return RedirectToAction("Index");
        }
Ejemplo n.º 9
0
        public ActionResult Index()
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<Semester, SemesterModel>();

              var ctx = new CourseContext();

              var result = memberMapper.Map<List<Semester>, List<SemesterModel>>(ctx.Semesters.ToList());

              return View(result);
        }
Ejemplo n.º 10
0
        public ActionResult Index()
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<Group, GroupModel>();

              var ctx = new CourseContext();

              var result = memberMapper.Map<List<Group>, List<GroupModel>>(ctx.Groups.ToList());

              return View(result);
        }
Ejemplo n.º 11
0
        public ActionResult Edit(int id, GroupModel model)
        {
            CourseContext ctx = new CourseContext();
              var group = ctx.Groups.FirstOrDefault(c => c.ID == model.ID);

              group.Name = model.Name;
              group.Identifier = model.Identifier;

              ctx.SaveChanges();

              return RedirectToAction("Index");
        }
Ejemplo n.º 12
0
        public ActionResult Index()
        {
            var memberMapper = new MemberMapper();
              memberMapper.CreateMap<Teacher, TeacherModel>(source => new TeacherModel()
              {
            RoomNr = source.RoomNumber,
            SchoolPhone = source.Phone,
            Identifier = source.IDNumber
              });

              var ctx = new CourseContext();

              var result = memberMapper.Map<List<Teacher>, List<TeacherModel>>(ctx.Teachers.ToList());

              return View(result);
        }
Ejemplo n.º 13
0
        public ActionResult Update(TeacherModel model)
        {
            CourseContext ctx = new CourseContext();
              var teacher = ctx.Teachers.FirstOrDefault(c => c.ID == model.ID);

              teacher.FirstName = model.FirstName;
              teacher.LastName = model.LastName;
              teacher.Email = model.Email;
              teacher.RoomNumber = model.RoomNr;
              teacher.Phone = model.SchoolPhone;

              ctx.SaveChanges();

              return RedirectToAction("Index");
        }