public async Task <IActionResult> Edit(AddSalidaViewModel view)
        {
            if (ModelState.IsValid)
            {
                var salida = this.ToSalida(view);

                try
                {
                    await this.salidaRepository.UpdateAsync(salida);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await this.salidaRepository.ExistAsync(salida.Id))
                    {
                        return(new NotFoundViewResult("SalidaNotFound"));
                    }

                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(view));
        }
        //GET: Salidas/Create
        public IActionResult Create()
        {
            var model = new AddSalidaViewModel
            {
                DiaSalida     = DateTime.UtcNow.Date,
                TiposDeSalida = this.tipoRepository.GetComboTipos(),
                Bomberos      = this.salidaRepository.GetComboUsers(),
                Bomberos2     = this.salidaRepository.GetComboUsers()
            };

            return(this.View(model));
        }
        public async Task <IActionResult> Create(AddSalidaViewModel view)
        {
            view.User = await this.userHelper.GetUserByEmailAsync(this.User.Identity.Name);

            if (ModelState.IsValid)
            {
                var salida = this.ToSalida(view);
                await this.salidaRepository.CreateAsync(salida);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(RedirectToAction(nameof(Create)));
            }
        }
 private Salida ToSalida(AddSalidaViewModel view)
 {
     return(new Salida
     {
         Id = view.Id,
         Bombero1 = view.Bombero1,
         EsReten1 = view.EsReten1,
         Bombero2 = view.Bombero2,
         EsReten2 = view.EsReten2,
         DiaSalida = view.DiaSalida,
         TipoSalida = view.TipoSalida,
         Descripcion = view.Descripcion,
         HoraSalida = view.HoraSalida,
         HoraRegreso = view.HoraRegreso,
         User = view.User
     });
 }