public async Task <ActionResult> Create(HorarioPersonaViewModel view)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(view.sFecha))
                    {
                        view.Fecha = DateTime.ParseExact(view.sFecha, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }
                    if (!string.IsNullOrEmpty(view.sHora))
                    {
                        view.Hora = TimeSpan.ParseExact(view.sHora, "g", CultureInfo.InvariantCulture, TimeSpanStyles.AssumeNegative);
                    }
                    HorarioPersona horarioPersona = new HorarioPersona();
                    AutoMapper.Mapper.Map(view, horarioPersona);
                    db.HorarioPersonas.Add(horarioPersona);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
            }

            ViewBag.PersonaId      = new SelectList(db.Personas, "PersonaId", "NombreCompleto", view.PersonaId);
            ViewBag.HorarioRubroId = new SelectList(db.HorarioRubros, "HorarioRubroId", "Nombre", view.HorarioRubroId);
            return(View(view));
        }
        public async Task <ActionResult> Delete(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                HorarioPersona horarioPersona = await db.HorarioPersonas.FindAsync(id);

                if (horarioPersona == null)
                {
                    return(HttpNotFound());
                }

                db.HorarioPersonas.Remove(horarioPersona);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(RedirectToAction("Index"));
            }
        }
        public async Task <ActionResult> Edit(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                HorarioPersona horarioPersona = await db.HorarioPersonas.FindAsync(id);

                if (horarioPersona == null)
                {
                    return(HttpNotFound());
                }
                ViewBag.PersonaId      = new SelectList(db.Personas, "PersonaId", "NombreCompleto", horarioPersona.PersonaId);
                ViewBag.HorarioRubroId = new SelectList(db.HorarioRubros, "HorarioRubroId", "Nombre", horarioPersona.HorarioRubroId);

                HorarioPersonaViewModel view = new HorarioPersonaViewModel();
                AutoMapper.Mapper.Map(horarioPersona, view);
                return(View(view));
            }
            catch (Exception)
            {
                return(View(new HorarioPersonaViewModel()));
            }
        }
        public async Task <ActionResult> Details(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                HorarioPersona horarioPersona = await db.HorarioPersonas.FindAsync(id);

                if (horarioPersona == null)
                {
                    return(HttpNotFound());
                }
                return(View(horarioPersona));
            }
            catch (Exception)
            {
                return(View(new HorarioPersona()));
            }
        }