public ActionResult Crear_registro(int id, int?menu) { registroLlamadasModel modelo = new registroLlamadasModel { tercero_id = id }; ViewBag.idtecero = id; ViewBag.tpllamada_rescate_id = new SelectList(context.icb_tpllamadarescate, "tpllamada_id", "tpllamada_nombre"); ViewBag.statusprospecto_id = new SelectList(context.icb_statusprospecto, "status_id", "status_nombre"); BuscarFavoritos(menu); return(View(modelo)); }
public ActionResult Crear_registro(registroLlamadasModel llamadas, int?menu) { if (ModelState.IsValid) { string idcotizacion = Request["idcotizacion"]; if (idcotizacion != null) { llamadas.cotizacion_id = Convert.ToInt32(idcotizacion); } ViewBag.idtecero = llamadas.tercero_id; llamadas.regllam_fecela = DateTime.Now; llamadas.regllam_usuela = Convert.ToInt32(Session["user_usuarioid"]); context.icb_registro_llamadas.Add(new icb_registro_llamadas { regllam_verbalizacion = llamadas.regllam_verbalizacion, regllam_prox_fecha = llamadas.regllam_prox_fecha, regllam_fecela = llamadas.regllam_fecela, tercero_id = llamadas.tercero_id, cotizacion_id = llamadas.cotizacion_id, statusprospecto_id = llamadas.statusprospecto_id, tpllamada_rescate_id = llamadas.tpllamada_rescate_id, regllam_usuela = llamadas.regllam_usuela }); bool resul = context.SaveChanges() > 0; if (resul) { icb_terceros tercero = context.icb_terceros.FirstOrDefault(x => x.tercero_id == llamadas.tercero_id); tercero.fecha_proximo_contacto = llamadas.regllam_prox_fecha; tercero.estado_prospecto = llamadas.statusprospecto_id; context.Entry(tercero).State = EntityState.Modified; context.SaveChanges(); TempData["mensaje"] = "Registro creado correctamente"; } else { TempData["mensaje_error"] = "Error al crear el registro de llamadas, por favor intente nuevamente"; } } ViewBag.tpllamada_rescate_id = new SelectList(context.icb_tpllamadarescate, "tpllamada_id", "tpllamada_nombre"); ViewBag.statusprospecto_id = new SelectList(context.icb_statusprospecto, "status_id", "status_nombre"); BuscarFavoritos(menu); return(View(llamadas)); }