Пример #1
0
        public ActionResult Edit(int?id, int?menu)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            bodega_concesionario horario = context.bodega_concesionario.Find(id);

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

            thorario_taller horarioBuscado = new thorario_taller
            {
                hora_inicial = horario.hora_inicial ?? new TimeSpan(),
                hora_final   = horario.hora_final ?? new TimeSpan(),
                bodega_id    = horario.id,
                lapso_tiempo = horario.lapso_tiempo ?? 0
            };

            ViewBag.bodega_id = new SelectList(context.bodega_concesionario.Where(x => x.es_taller), "id",
                                               "bodccs_nombre", horario.id);
            BuscarFavoritos(menu);
            return(View(horarioBuscado));
        }
Пример #2
0
        public ActionResult Create(thorario_taller modelo, int?menu)
        {
            if (ModelState.IsValid)
            {
                bodega_concesionario buscarBodega = context.bodega_concesionario.FirstOrDefault(x => x.id == modelo.bodega_id);
                if (buscarBodega != null)
                {
                    buscarBodega.hora_inicial         = modelo.hora_inicial;
                    buscarBodega.hora_final           = modelo.hora_final;
                    buscarBodega.lapso_tiempo         = modelo.lapso_tiempo;
                    context.Entry(buscarBodega).State = EntityState.Modified;
                    int guardar = context.SaveChanges();
                    if (guardar > 0)
                    {
                        TempData["mensaje"] = "La creación del horario fue exitosa";
                    }
                }
                else
                {
                    TempData["mensaje_error"] = "Error de conexion con la base de datos, por favor valide...";
                }
            }

            ViewBag.bodega_id =
                new SelectList(context.bodega_concesionario.Where(x => x.es_taller), "id", "bodccs_nombre");
            BuscarFavoritos(menu);
            return(View());
        }
Пример #3
0
        public ActionResult Edit(thorario_taller modelo, int?menu)
        {
            if (ModelState.IsValid)
            {
                bodega_concesionario buscarSiExiste = context.bodega_concesionario.FirstOrDefault(x => x.id == modelo.bodega_id);
                if (buscarSiExiste != null)
                {
                    buscarSiExiste.hora_inicial         = modelo.hora_inicial;
                    buscarSiExiste.hora_final           = modelo.hora_final;
                    buscarSiExiste.lapso_tiempo         = modelo.lapso_tiempo;
                    context.Entry(buscarSiExiste).State = EntityState.Modified;
                    int guardar = context.SaveChanges();
                    if (guardar > 0)
                    {
                        TempData["mensaje"] = "La actualización del horario fue exitosa";
                    }
                    else
                    {
                        TempData["mensaje_error"] = "Error de conexion con la base de datos, por favor valide...";
                    }
                }
                else
                {
                    TempData["mensaje_error"] = "Error de conexion con la base de datos, por favor valide...";
                    //if (buscarSiExiste.id == modelo.id)
                    //{
                    //    buscarSiExiste.bodega_id = modelo.bodega_id;
                    //    buscarSiExiste.hora_inicial = modelo.hora_inicial;
                    //    buscarSiExiste.hora_final = modelo.hora_final;
                    //    buscarSiExiste.lapso_tiempo = modelo.lapso_tiempo;
                    //    context.Entry(buscarSiExiste).State = System.Data.Entity.EntityState.Modified;
                    //    try
                    //    {
                    //        var guardar = context.SaveChanges();
                    //        if (guardar > 0)
                    //        {
                    //            TempData["mensaje"] = "La actualización de la bahía fue exitosa";
                    //        }
                    //        else
                    //        {
                    //            TempData["mensaje_error"] = "Error de conexion con la base de datos, por favor valide...";
                    //        }

                    //    }
                    //    catch (DbEntityValidationException e)
                    //    {
                    //        foreach (var eve in e.EntityValidationErrors)
                    //        {
                    //            Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                    //                eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    //            foreach (var ve in eve.ValidationErrors)
                    //            {
                    //                Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                    //                    ve.PropertyName, ve.ErrorMessage);
                    //            }
                    //        }
                    //        throw;
                    //    }

                    //}
                    //else
                    //{
                    //    TempData["mensaje_error"] = "El horario con la bodega seleccionada ya se encuentra creada, por favor verifique...";
                    //}
                }
            }

            ViewBag.bodega_id = new SelectList(context.bodega_concesionario.Where(x => x.es_taller), "id",
                                               "bodccs_nombre", modelo.bodega_id);
            BuscarFavoritos(menu);
            return(View(modelo));
        }