Beispiel #1
0
        public ActionResult Details(int id)
        {
            try
            {
                var repo           = new IndividualRepository(context);
                var repoAssignment = new AssignedRepository(context);
                var repoCursos     = new CourseRepository(context);

                var individual  = repo.Find(id);
                var indi        = MapperHelpers.Map <IndividualViewModel>(individual);
                var assginments = repoAssignment.Query(x => x.IndividualId == individual.Id).OrderByDescending(x => x.AssingmentDate).ToList();

                foreach (var item in assginments)
                {
                    var course      = repoCursos.Query(x => x.Id == item.CourseId).ToList();
                    var courseModel = MapperHelpers.Map <ICollection <CoursesViewModel> >(course).SingleOrDefault();
                    indi.Courses.Add(courseModel);
                }

                return(View(indi));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index"));
            }
        }
Beispiel #2
0
        // GET: Individual/Details/5
        public ActionResult Details(int id)
        {
            var repository = new IndividualRepository(context);
            var individual = repository.Find(id);
            var model      = MapperHelper.Map <IndividualViewModel>(individual);

            return(View(model));
        }
Beispiel #3
0
        // GET: Invidivual/Edit/5
        public ActionResult Edit(int id)
        {
            var repo       = new IndividualRepository(context);
            var model      = repo.Find(id);
            var individual = MapperHelpers.Map <EditIndividualViewModel>(model);

            return(View(individual));
        }
Beispiel #4
0
        // GET: Individual/Edit/5
        public ActionResult Edit(int id)
        {
            var repositorio = new IndividualRepository(context);
            var individual  = repositorio.Find(id);
            var model       = MapperHelper.Map <EditIndividualViewModel>(individual);

            model.EmailAnterior = model.Email;
            return(View(model));
        }
Beispiel #5
0
        // GET: individual/Edit/5
        public ActionResult Edit(int id)
        {
            var repository = new IndividualRepository(context);
            var entity     = repository.Find(id);
            var model      = MapperHelper.Map <IndividualViewModel>(entity);

            ModelState.Remove("Email");
            return(View(model));
        }
Beispiel #6
0
        // GET: individual/Delete/5
        public ActionResult Delete(int id)
        {
            var repository = new IndividualRepository(context);
            var entity     = repository.Find(id);
            var model      = MapperHelper.Map <IndividualViewModel>(entity);

            context.SaveChanges();
            return(View(model));
        }
Beispiel #7
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         var repository = new IndividualRepository(context);
         var entity     = repository.Find(id);
         repository.Delete(entity);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(new IndividualViewModel()));
     }
 }