public async Task <IActionResult> Update(LlamadaViewModel model) { try { if (!ModelState.IsValid) { return(StatusCode(400, "Modelo no válido.")); } LlamadaEntity llamadaEntity = await _context.Llamadas.FindAsync(model.Id); if (llamadaEntity == null) { return(StatusCode(404, "Llamada no existe.")); } llamadaEntity.Mensaje = model.Mensaje == null || model.Mensaje == "" ? llamadaEntity.Mensaje : model.Mensaje; llamadaEntity.TipoLlamadaEntityId = model.TipoLlamadaEntityId == 0 ? llamadaEntity.TipoLlamadaEntityId : model.TipoLlamadaEntityId; llamadaEntity.TipoPersonaEntityId = model.TipoPersonaEntityId == 0 ? llamadaEntity.TipoPersonaEntityId : model.TipoPersonaEntityId; _context.Llamadas.Update(llamadaEntity); await _context.SaveChangesAsync(); return(StatusCode(200)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
/// <summary> /// Converts data from reader to entity /// </summary> protected virtual LlamadaEntity GetLlamadaFromReader(IDataReader reader) { LlamadaEntity entity_Llamada = null; try { entity_Llamada = new LlamadaEntity(); entity_Llamada.IdLlamada = (int?)(GetFromReader(reader, "IdLlamada")); entity_Llamada.IdUsuario = (int?)(GetFromReader(reader, "IdUsuario")); entity_Llamada.Tipo_Llamada = (int?)(GetFromReader(reader, "Tipo_Llamada")); entity_Llamada.Contrato = (long?)(GetFromReader(reader, "Contrato")); entity_Llamada.Detalle = (String)(GetFromReader(reader, "Detalle", IsString: true)); entity_Llamada.Solucion = (String)(GetFromReader(reader, "Solucion", IsString: true)); entity_Llamada.Fecha = (String)(GetFromReader(reader, "Fecha")); entity_Llamada.HoraInicio = (String)(GetFromReader(reader, "HoraInicio", IsString: true)); entity_Llamada.HoraFin = (String)(GetFromReader(reader, "HoraFin", IsString: true)); entity_Llamada.IdTurno = (int?)(GetFromReader(reader, "IdTurno")); entity_Llamada.Clv_Queja = (long?)(GetFromReader(reader, "Clv_Queja")); entity_Llamada.IdConexion = (int?)(GetFromReader(reader, "IdConexion")); entity_Llamada.Clv_Trabajo = (int?)(GetFromReader(reader, "Clv_Trabajo")); entity_Llamada.Clv_TipSer = (int?)(GetFromReader(reader, "Clv_TipSer")); entity_Llamada.Clv_Problema = (int?)(GetFromReader(reader, "Clv_Problema")); entity_Llamada.SiEsCliente = (bool?)(GetFromReader(reader, "SiEsCliente")); entity_Llamada.Clv_Motivo = (int?)(GetFromReader(reader, "Clv_Motivo")); entity_Llamada.Ciudad = (string)(GetFromReader(reader, "Ciudad", IsString: true)); } catch (Exception ex) { throw new Exception("Error converting Llamada data to entity", ex); } return(entity_Llamada); }
public LlamadaViewModel(LlamadaEntity x) { this.Id = x.Id; this.Mensaje = x.Mensaje; this.TipoLlamadaEntityId = x.TipoLlamadaEntityId; this.TipoPersonaEntityId = x.TipoPersonaEntityId; }
public async Task <IActionResult> Create(LlamadaViewModel model) { LlamadaEntity llamadaEntity = new LlamadaEntity(); try { if (!ModelState.IsValid) { return(StatusCode(400, "Modelo no válido.")); } llamadaEntity.Mensaje = model.Mensaje; llamadaEntity.TipoLlamadaEntityId = model.TipoLlamadaEntityId; llamadaEntity.TipoPersonaEntityId = model.TipoPersonaEntityId; await _context.Llamadas.AddAsync(llamadaEntity); await _context.SaveChangesAsync(); return(RedirectToAction("GetById", "Llamadas", new { id = llamadaEntity.Id })); } catch (Exception ex) { return(StatusCode(500, ex)); }finally { llamadaEntity = null; } }
public ActionResult Edit(int id = 0) { PermisosAccesoDeniedEdit("Llamada"); ViewBag.CustomScriptsPageValid = BuildScriptPageValid(); LlamadaEntity objLlamada = proxy.GetLlamada(id); ViewBag.VBUsuario = new SelectList(proxyUsuario.GetUsuarioList().OrderBy(x => x.Nombre.Trim()).ToList(), "IdUsuario", "Nombre"); ViewBag.VBTurnos = new SelectList(proxyTurnos.GetTurnoList().OrderBy(x => x.Turno.Trim()).ToList(), "IdTurno", "Turno"); ViewBag.VBConexion = new SelectList(proxyConexion.GetConexionList().OrderBy(x => x.Plaza.Trim()).ToList(), "IdConexion", "Plaza"); ViewBag.VBTrabajo = new SelectList(proxyTrabajo.GetTrabajoList().OrderBy(x => x.TRABAJO.Trim()).ToList(), "Clv_Trabajo", "TRABAJO"); ViewBag.VBTipServ = new SelectList(proxyTipServ.GetTipServList().OrderBy(x => x.Concepto.Trim()).ToList(), "Clv_TipSer", "Concepto"); ViewBag.VBCLIENTE = new SelectList(proxyCLIENTE.GetCLIENTEList().OrderBy(x => x.NOMBRE.Trim()).ToList(), "Contrato", "NOMBRE"); ViewBag.VBQueja = new SelectList(proxyQueja.GetQuejaList().OrderBy(x => x.Problema.Trim()).ToList(), "Clv_Queja", "Problema"); if (objLlamada == null) { return(HttpNotFound()); } return(View(objLlamada)); }
public ActionResult Create(LlamadaEntity objLlamada) { if (ModelState.IsValid) { objLlamada.BaseRemoteIp = RemoteIp; objLlamada.BaseIdUser = LoggedUserName; int result = proxy.AddLlamada(objLlamada); if (result == -1) { ViewBag.VBUsuario = new SelectList(proxyUsuario.GetUsuarioList().OrderBy(x => x.Nombre.Trim()).ToList(), "IdUsuario", "Nombre", objLlamada.IdUsuario); ViewBag.VBTurnos = new SelectList(proxyTurnos.GetTurnoList().OrderBy(x => x.Turno.Trim()).ToList(), "IdTurno", "Turno", objLlamada.IdTurno); ViewBag.VBConexion = new SelectList(proxyConexion.GetConexionList().OrderBy(x => x.Plaza.Trim()).ToList(), "IdConexion", "Plaza", objLlamada.IdConexion); ViewBag.VBTrabajo = new SelectList(proxyTrabajo.GetTrabajoList().OrderBy(x => x.TRABAJO.Trim()).ToList(), "Clv_Trabajo", "TRABAJO", objLlamada.Clv_Trabajo); ViewBag.VBTipServ = new SelectList(proxyTipServ.GetTipServList().OrderBy(x => x.Concepto.Trim()).ToList(), "Clv_TipSer", "Concepto", objLlamada.Clv_TipSer); ViewBag.VBCLIENTE = new SelectList(proxyCLIENTE.GetCLIENTEList().OrderBy(x => x.NOMBRE.Trim()).ToList(), "Contrato", "NOMBRE", objLlamada.Contrato); ViewBag.VBQueja = new SelectList(proxyQueja.GetQuejaList().OrderBy(x => x.Problema.Trim()).ToList(), "Clv_Queja", "Problema", objLlamada.Clv_Queja); AssingMessageScript("El Llamada ya existe en el sistema.", "error", "Error", true); CheckNotify(); return(View(objLlamada)); } if (result > 0) { AssingMessageScript("Se dio de alta el Llamada en el sistema.", "success", "Éxito", true); return(RedirectToAction("Index")); } } return(View(objLlamada)); }
/// <summary> /// Edits a Llamada ///</summary> /// <param name="Llamada"> Objeto Llamada a editar </param> public override int EditLlamada(LlamadaEntity entity_Llamada) { int result = 0; using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Llamada.ConnectionString)) { SqlCommand comandoSql = CreateCommand("Softv_LlamadaEdit", connection); AssingParameter(comandoSql, "@IdLlamada", entity_Llamada.IdLlamada); AssingParameter(comandoSql, "@IdUsuario", entity_Llamada.IdUsuario); AssingParameter(comandoSql, "@Tipo_Llamada", entity_Llamada.Tipo_Llamada); AssingParameter(comandoSql, "@Contrato", entity_Llamada.Contrato); AssingParameter(comandoSql, "@Detalle", entity_Llamada.Detalle); AssingParameter(comandoSql, "@Solucion", entity_Llamada.Solucion); AssingParameter(comandoSql, "@Fecha", entity_Llamada.Fecha); AssingParameter(comandoSql, "@HoraInicio", entity_Llamada.HoraInicio); AssingParameter(comandoSql, "@HoraFin", entity_Llamada.HoraFin); AssingParameter(comandoSql, "@IdTurno", entity_Llamada.IdTurno); AssingParameter(comandoSql, "@Clv_Queja", entity_Llamada.Clv_Queja); AssingParameter(comandoSql, "@IdConexion", entity_Llamada.IdConexion); AssingParameter(comandoSql, "@Clv_Trabajo", entity_Llamada.Clv_Trabajo); AssingParameter(comandoSql, "@Clv_TipSer", entity_Llamada.Clv_TipSer); try { if (connection.State == ConnectionState.Closed) { connection.Open(); } result = int.Parse(ExecuteNonQuery(comandoSql).ToString()); } catch (Exception ex) { throw new Exception("Error updating Llamada " + ex.Message, ex); } finally { if (connection != null) { connection.Close(); } } } return(result); }
/// <summary> ///</summary> /// <param name="Llamada"> Object Llamada added to List</param> public override int AddLlamada(LlamadaEntity entity_Llamada) { int result = 0; using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Llamada.ConnectionString)) { SqlCommand comandoSql = CreateCommand("Softv_LlamadaAdd", connection); AssingParameter(comandoSql, "@IdLlamada", null, pd: ParameterDirection.Output, IsKey: true); AssingParameter(comandoSql, "@IdUsuario", entity_Llamada.IdUsuario); AssingParameter(comandoSql, "@Tipo_Llamada", entity_Llamada.Tipo_Llamada); AssingParameter(comandoSql, "@Contrato", entity_Llamada.Contrato); AssingParameter(comandoSql, "@Detalle", entity_Llamada.Detalle); AssingParameter(comandoSql, "@Solucion", entity_Llamada.Solucion); AssingParameter(comandoSql, "@Fecha", entity_Llamada.Fecha); AssingParameter(comandoSql, "@HoraInicio", entity_Llamada.HoraInicio); AssingParameter(comandoSql, "@HoraFin", entity_Llamada.HoraFin); AssingParameter(comandoSql, "@IdTurno", entity_Llamada.IdTurno); AssingParameter(comandoSql, "@Clv_Queja", entity_Llamada.Clv_Queja); AssingParameter(comandoSql, "@IdConexion", entity_Llamada.IdConexion); AssingParameter(comandoSql, "@Clv_Trabajo", entity_Llamada.Clv_Trabajo); AssingParameter(comandoSql, "@Clv_TipSer", entity_Llamada.Clv_TipSer); AssingParameter(comandoSql, "@Clv_Problema", entity_Llamada.Clv_Problema); try { if (connection.State == ConnectionState.Closed) { connection.Open(); } result = ExecuteNonQuery(comandoSql); } catch (Exception ex) { throw new Exception("Error adding Llamada " + ex.Message, ex); } finally { connection.Close(); } result = (int)comandoSql.Parameters["@IdLlamada"].Value; } return(result); }
public ActionResult Details(int id = 0) { LlamadaEntity objLlamada = proxy.GetLlamada(id); if (objLlamada == null) { return(HttpNotFound()); } return(PartialView(objLlamada)); }
public static LlamadaEntity GetOneDeep(int?IdLlamada) { LlamadaEntity result = ProviderSoftv.Llamada.GetLlamadaById(IdLlamada); if (result.IdUsuario != null) { result.Usuario = ProviderSoftv.Usuario.GetUsuarioById(result.IdUsuario); } if (result.IdTurno != null) { result.Turnos = ProviderSoftv.Turno.GetTurnoById(result.IdTurno); } if (result.IdConexion != null) { result.Conexion = ProviderSoftv.Conexion.GetConexionById(result.IdConexion); } if (result.Clv_Trabajo != null) { result.Trabajo = ProviderSoftv.Trabajo.GetTrabajoById(result.Clv_Trabajo); } if (result.Clv_TipSer != null) { result.TipServ = ProviderSoftv.TipServ.GetTipServById(result.Clv_TipSer); } if (result.Contrato != null) { result.CLIENTE = ProviderSoftv.CLIENTE.GetCLIENTEById(result.Contrato); } if (result.Clv_Queja != null) { result.Queja = ProviderSoftv.Queja.GetQuejaById(result.Clv_Queja); } return(result); }
/// <summary> /// Gets Llamada by ///</summary> public override LlamadaEntity GetLlamadaById(int?IdLlamada) { using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Llamada.ConnectionString)) { SqlCommand comandoSql = CreateCommand("Softv_LlamadaGetById", connection); LlamadaEntity entity_Llamada = null; AssingParameter(comandoSql, "@IdLlamada", IdLlamada); IDataReader rd = null; try { if (connection.State == ConnectionState.Closed) { connection.Open(); } rd = ExecuteReader(comandoSql, CommandBehavior.SingleRow); if (rd.Read()) { entity_Llamada = GetLlamadaFromReader(rd); } } catch (Exception ex) { throw new Exception("Error getting data Llamada " + ex.Message, ex); } finally { if (connection != null) { connection.Close(); } if (rd != null) { rd.Close(); } } return(entity_Llamada); } }
public async Task <IActionResult> Delete(int?id) { try { if (id == null) { return(StatusCode(400, "Identificador nullo")); } LlamadaEntity llamadaEntity = await _context.Llamadas.FindAsync(id); if (llamadaEntity == null) { return(StatusCode(404, "No se encontro la llamada")); } _context.Llamadas.Remove(llamadaEntity); await _context.SaveChangesAsync(); return(StatusCode(200)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public ActionResult QuickIndex(int?page, int?pageSize, bool?Tipo_Llamada, String Detalle, String Solucion, DateTime?Fecha, DateTime?HoraInicio, DateTime?HoraFin, int?IdUsuario, int?IdTurno, int?IdConexion, int?Clv_Trabajo, int?Clv_TipSer, int?Contrato, int?Clv_Queja) { int pageNumber = (page ?? 1); int pSize = pageSize ?? SoftvMVC.Properties.Settings.Default.pagnum; SoftvList <LlamadaEntity> listResult = null; List <LlamadaEntity> listLlamada = new List <LlamadaEntity>(); LlamadaEntity objLlamada = new LlamadaEntity(); LlamadaEntity objGetLlamada = new LlamadaEntity(); if ((Tipo_Llamada != null)) { objLlamada.Tipo_Llamada = Tipo_Llamada; } if ((Detalle != null && Detalle.ToString() != "")) { objLlamada.Detalle = Detalle; } if ((Solucion != null && Solucion.ToString() != "")) { objLlamada.Solucion = Solucion; } if ((Fecha != null)) { objLlamada.Fecha = Fecha; } if ((HoraInicio != null)) { objLlamada.HoraInicio = HoraInicio; } if ((HoraFin != null)) { objLlamada.HoraFin = HoraFin; } if ((IdUsuario != null)) { objLlamada.IdUsuario = IdUsuario; } if ((IdTurno != null)) { objLlamada.IdTurno = IdTurno; } if ((IdConexion != null)) { objLlamada.IdConexion = IdConexion; } if ((Clv_Trabajo != null)) { objLlamada.Clv_Trabajo = Clv_Trabajo; } if ((Clv_TipSer != null)) { objLlamada.Clv_TipSer = Clv_TipSer; } if ((Contrato != null)) { objLlamada.Contrato = Contrato; } if ((Clv_Queja != null)) { objLlamada.Clv_Queja = Clv_Queja; } pageNumber = pageNumber == 0 ? 1 : pageNumber; listResult = proxy.GetLlamadaPagedListXml(pageNumber, pSize, Globals.SerializeTool.Serialize(objLlamada)); if (listResult.Count == 0) { int tempPageNumber = (int)(listResult.totalCount / pSize); pageNumber = (int)(listResult.totalCount / pSize) == 0 ? 1 : tempPageNumber; listResult = proxy.GetLlamadaPagedListXml(pageNumber, pSize, Globals.SerializeTool.Serialize(objLlamada)); } listResult.ToList().ForEach(x => listLlamada.Add(x)); var LlamadaAsIPagedList = new StaticPagedList <LlamadaEntity>(listLlamada, pageNumber, pSize, listResult.totalCount); if (LlamadaAsIPagedList.Count > 0) { return(PartialView(LlamadaAsIPagedList)); } else { var result = new { tipomsj = "warning", titulomsj = "Aviso", Success = "False", Message = "No se encontraron registros con los criterios de búsqueda ingresados." }; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public int UpdateLlamada(LlamadaEntity objLlamada) { return(Llamada.Edit(objLlamada)); }
/// <summary> /// Abstract method to add Llamada /// /summary> /// <param name="Llamada"></param> /// <returns></returns> public abstract int AddLlamada(LlamadaEntity entity_Llamada);
public static int Edit(LlamadaEntity objLlamada) { int result = ProviderSoftv.Llamada.EditLlamada(objLlamada); return(result); }
public static int Add(LlamadaEntity objLlamada) { int result = ProviderSoftv.Llamada.AddLlamada(objLlamada); return(result); }
/// <summary> /// Abstract method to update Llamada /// </summary> public abstract int EditLlamada(LlamadaEntity entity_Llamada);
public int AddLlamada(LlamadaEntity objLlamada) { return(Llamada.Add(objLlamada)); }