public async Task <IActionResult> EditConceptoConjunto(string id)
        {
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    var ConceptoConjuntoNomina = new ConceptoConjuntoNomina {
                        IdConceptoConjunto = Convert.ToInt32(id)
                    };
                    var respuesta = await apiServicio.ObtenerElementoAsync1 <Response>(ConceptoConjuntoNomina, new Uri(WebApp.BaseAddress),
                                                                                       "api/ConceptoConjuntoNomina/ObtenerConceptoConjuntoNomina");

                    if (respuesta.IsSuccess)
                    {
                        var vista = JsonConvert.DeserializeObject <ConceptoConjuntoNomina>(respuesta.Resultado.ToString());
                        await CargarComboxConceptoConjunto();

                        return(View(vista));
                    }
                }

                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
            }
            catch (Exception)
            {
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
            }
        }
        public async Task <IActionResult> CreateConceptoConjunto(ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            if (!ModelState.IsValid)
            {
                return(View(ConceptoConjuntoNomina));
            }
            Response response = new Response();

            try
            {
                if (ObtenerConceptoNomina().IdConcepto > 0)
                {
                    ConceptoConjuntoNomina.IdConcepto = ObtenerConceptoNomina().IdConcepto;
                    response = await apiServicio.InsertarAsync(ConceptoConjuntoNomina,
                                                               new Uri(WebApp.BaseAddress),
                                                               "api/ConceptoConjuntoNomina/InsertarConceptoConjuntoNomina");

                    if (response.IsSuccess)
                    {
                        return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}", "IndexConceptoConjunto"));
                    }

                    this.TempData["Mensaje"] = $"{Mensaje.Error}|{response.Message}";
                    await CargarComboxConceptoConjunto();

                    return(View(ConceptoConjuntoNomina));
                }
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
            }
            catch (Exception)
            {
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
            }
        }
        public async Task <IActionResult> DeleteConceptoConjunto(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}"));
                }
                var tipoConjuntoEliminar = new ConceptoConjuntoNomina {
                    IdConceptoConjunto = Convert.ToInt32(id)
                };

                var response = await apiServicio.EliminarAsync(tipoConjuntoEliminar, new Uri(WebApp.BaseAddress)
                                                               , "api/ConceptoConjuntoNomina/EliminarConceptoConjuntoNomina");

                if (response.IsSuccess)
                {
                    return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}", "IndexConceptoConjunto"));
                }
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.BorradoNoSatisfactorio}"));
            }
            catch (Exception)
            {
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorEliminar}"));
            }
        }
예제 #4
0
        public async Task <Response> ObtenerConceptoConjuntoNomina([FromBody] ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            try
            {
                var conceptoConjuntoNomina = await db.ConceptoConjuntoNomina.SingleOrDefaultAsync(m => m.IdConceptoConjunto == ConceptoConjuntoNomina.IdConceptoConjunto);

                if (conceptoConjuntoNomina == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.RegistroNoEncontrado,
                    });
                }

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                    Resultado = conceptoConjuntoNomina,
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
        public async Task <IActionResult> CreateConceptoConjunto(ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            if (!ModelState.IsValid)
            {
                InicializarMensaje(null);
                return(View(ConceptoConjuntoNomina));
            }
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(ConceptoConjuntoNomina,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/ConceptoConjuntoNomina/InsertarConceptoConjuntoNomina");

                if (response.IsSuccess)
                {
                    return(this.Redireccionar($"{Mensaje.Satisfactorio}|{Mensaje.Satisfactorio}"));
                }

                ViewData["Error"] = response.Message;
                await CargarComboxConceptoConjunto();

                return(View(ConceptoConjuntoNomina));
            }
            catch (Exception)
            {
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
            }
        }
예제 #6
0
        public async Task <Response> PostConceptoConjuntoNomina([FromBody] ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            try
            {
                if (!await Existe(ConceptoConjuntoNomina))
                {
                    db.ConceptoConjuntoNomina.Add(ConceptoConjuntoNomina);
                    await db.SaveChangesAsync();

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio,
                        Resultado = ConceptoConjuntoNomina,
                    });
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
        public async Task <IActionResult> CreateConceptoConjunto(string mensaje)
        {
            InicializarMensaje(mensaje);
            await CargarComboxConceptoConjunto();

            var vista = new ConceptoConjuntoNomina {
                Suma = false, Resta = false
            };

            return(View(vista));
        }
        public async Task <IActionResult> CreateConceptoConjunto(string mensaje)
        {
            if (ObtenerConceptoNomina().IdConcepto > 0)
            {
                await CargarComboxConceptoConjunto();

                var vista = new ConceptoConjuntoNomina {
                    Suma = true, Resta = false
                };
                return(View(vista));
            }
            return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
        }
예제 #9
0
        private async Task <bool> Existe(ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            var conjunto = ConceptoConjuntoNomina.IdConjunto;
            var concepto = ConceptoConjuntoNomina.IdConcepto;
            var ConceptoConjuntoNominarespuesta = await db.ConceptoConjuntoNomina.Where(p => p.IdConcepto == concepto && p.IdConjunto == conjunto).FirstOrDefaultAsync();

            if (ConceptoConjuntoNominarespuesta == null || ConceptoConjuntoNominarespuesta.IdConceptoConjunto == ConceptoConjuntoNomina.IdConceptoConjunto)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #10
0
        public async Task <Response> EditarConceptoConjuntoNomina([FromBody] ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            try
            {
                if (await Existe(ConceptoConjuntoNomina))
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var ConceptoConjuntoNominaActualizar = await db.ConceptoConjuntoNomina.Where(x => x.IdConceptoConjunto == ConceptoConjuntoNomina.IdConceptoConjunto).FirstOrDefaultAsync();

                if (ConceptoConjuntoNominaActualizar == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                    });
                }

                ConceptoConjuntoNominaActualizar.IdConcepto = ConceptoConjuntoNomina.IdConcepto;
                ConceptoConjuntoNominaActualizar.IdConjunto = ConceptoConjuntoNomina.IdConjunto;
                ConceptoConjuntoNominaActualizar.Suma       = ConceptoConjuntoNomina.Suma;
                ConceptoConjuntoNominaActualizar.Resta      = ConceptoConjuntoNomina.Resta;
                db.ConceptoConjuntoNomina.Update(ConceptoConjuntoNominaActualizar);
                await db.SaveChangesAsync();

                return(new Response
                {
                    IsSuccess = true,
                    Resultado = ConceptoConjuntoNominaActualizar
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
예제 #11
0
        public async Task <Response> EliminarConceptoConjuntoNomina([FromBody] ConceptoConjuntoNomina ConceptoConjuntoNomina)
        {
            try
            {
                var respuesta = await db.ConceptoConjuntoNomina.Where(m => m.IdConceptoConjunto == ConceptoConjuntoNomina.IdConceptoConjunto).FirstOrDefaultAsync();

                if (respuesta == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.RegistroNoEncontrado,
                    });
                }
                db.ConceptoConjuntoNomina.Remove(respuesta);
                await db.SaveChangesAsync();

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                if (ex.InnerException.InnerException.Message.Contains("FK"))
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.BorradoNoSatisfactorio,
                    });
                }
                else
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = ex.InnerException.InnerException.Message,
                    });
                }
            }
        }