Esempio n. 1
0
        public ActionResult CargarGoleadores(int id)         //Estaría bueno que el parámetro se llame partidoId
        {
            var partido    = Context.Partidos.Single(x => x.Id == id);
            var goleadores = Context.Goleadores.Where(x => x.PartidoId == id).ToList();
            var vm         = VMM.MapForCargarGoleadores(goleadores, partido);

            return(View(vm));
        }
Esempio n. 2
0
        public ActionResult CargarGoleadores(CargarGoleadoresVM vm)
        {
            ValidarGoleadores(vm);
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("CargarGoleadores", new { id = vm.PartidoId }));
            }

            var model = Context.Partidos.Find(vm.PartidoId);

            var goleadores = Context.Goleadores.Where(x => x.PartidoId == model.Id);

            Context.Goleadores.RemoveRange(goleadores);

            VMM.MapForCargarGoleadores(vm, model);

            Context.SaveChanges();

            return(RedirectToAction("Details", new { id = model.Id }));
        }