示例#1
0
        public ActionResult Editar(int id)
        {
            var viewModel = new PartidoCreateUpdateViewModel(partidoBusiness.GetPartido(id));

            viewModel.ListaDeJugadores = FillListaDeJugadores();
            viewModel.ListaDeCanchas   = FillListaDeCanchas();
            return(View(viewModel));
        }
示例#2
0
        public ActionResult Agregar()
        {
            var viewModel = new PartidoCreateUpdateViewModel
            {
                FechaComienzo    = DateTime.Now.AddDays(1),
                ListaDeJugadores = FillListaDeJugadores(),
                ListaDeCanchas   = FillListaDeCanchas()
            };

            return(View(viewModel));
        }
示例#3
0
        public ActionResult Agregar(PartidoCreateUpdateViewModel partidoCreateUpdateViewModel)
        {
            if (ModelState.IsValid)
            {
                var errores = new List <string>();
                var exito   = partidoBusiness.AddPartido(partidoCreateUpdateViewModel.FechaComienzo, partidoCreateUpdateViewModel.IdJugadorLocal, partidoCreateUpdateViewModel.IdJugadorVisitante, partidoCreateUpdateViewModel.IdCancha, errores);
                if (exito)
                {
                    return(RedirectToAction("Index"));
                }

                foreach (var error in errores)
                {
                    ModelState.AddModelError(string.Empty, error);
                }
            }

            partidoCreateUpdateViewModel.ListaDeJugadores = FillListaDeJugadores();
            partidoCreateUpdateViewModel.ListaDeCanchas   = FillListaDeCanchas();

            return(View(partidoCreateUpdateViewModel));
        }