Exemplo n.º 1
0
        public async Task <ActionResult> mtdInsetarOficiales([FromBody] Agentes agente)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();
                var response = await context.tbagentes.FirstOrDefaultAsync(x => x.str_nombre == agente.str_nombre);

                if (response == null)
                {
                    agente.last_modified_date = horadeTransaccion.Value;;
                    agente.created_date       = horadeTransaccion.Value;
                    context.tbagentes.Add(agente);
                    await context.SaveChangesAsync();

                    return(Ok());
                }

                //ModelState.AddModelError("token", "El agente ya se encuentra registrado");
                //return BadRequest(ModelState);
                return(Json(new { token = "El oficial ya se encuentra registrado" }));
            }
            catch (Exception ex)
            {
                //    ModelState.AddModelError("token", ex.Message);
                //    return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> mtdModificarOficial(int id, [FromBody] Agentes agente)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();
                var response = await context.tbagentes.FirstOrDefaultAsync(x => x.id == id);

                if (response.id != id)
                {
                    return(NotFound());
                }
                response.intidzona_id       = agente.intidzona_id;
                response.last_modified_by   = agente.last_modified_by;
                response.last_modified_date = horadeTransaccion.Value;
                response.intidconcesion_id  = agente.intidconcesion_id;
                response.str_nombre         = agente.str_nombre;

                await context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(Json(new { token = ex.Message }));
            }
        }
        public async Task <ActionResult <Vehiculos> > mtdIngresarVehiculo([FromBody] Vehiculos vehiculos)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();

                var response = await context.tbvehiculos.FirstOrDefaultAsync(x => x.str_placas == vehiculos.str_placas);

                if (response == null)
                {
                    vehiculos.created_date       = horadeTransaccion.Value;
                    vehiculos.last_modified_date = horadeTransaccion.Value;
                    context.tbvehiculos.Add(vehiculos);
                    await context.SaveChangesAsync();

                    return(Ok());
                }

                //ModelState.AddModelError("token", "La placas que intenta registrar ya se encuentra registradas");
                //return BadRequest(ModelState);
                return(Json(new { token = "La placas que intenta registrar ya se encuentra registradas" }));
            }

            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
        public async Task <ActionResult> mtdActualizaVehiculo(int id, [FromBody] Vehiculos vehiculos)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();

                var response = await context.tbvehiculos.FirstOrDefaultAsync(x => x.id == id);

                if (response.id != id)
                {
                    return(BadRequest());
                }
                response.last_modified_by   = vehiculos.last_modified_by;
                response.last_modified_date = horadeTransaccion.Value;
                response.bit_status         = vehiculos.bit_status;
                response.str_color          = vehiculos.str_color;
                response.str_modelo         = vehiculos.str_modelo;
                response.str_marca          = vehiculos.str_marca;
                response.str_placas         = vehiculos.str_placas;
                // response.intidconcesion_id = vehiculos.intidconcesion_id;

                await context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult> mtdIngresarComerciante([FromBody] Comerciantes comerciantes)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();
                string strComercianteN = comerciantes.str_nombre + ' ' + comerciantes.str_apellido_ap + ' ' + comerciantes.str_apellido_mat;
                var    response        = await context.tbcomerciantes.FirstOrDefaultAsync(x => x.str_nombre + ' ' + x.str_apellido_ap + x.str_apellido_mat == strComercianteN);

                if (response == null)
                {
                    comerciantes.created_date       = horadeTransaccion.Value;
                    comerciantes.last_modified_date = horadeTransaccion.Value;
                    context.tbcomerciantes.Add(comerciantes);
                    await context.SaveChangesAsync();

                    return(Ok());
                }
                //ModelState.AddModelError("token", "El comerciante ya se encuentra registrado");
                //return BadRequest(ModelState);
                return(Json(new { token = "El comerciante ya se encuentra registrado" }));
            }

            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
        public async Task <ActionResult <Saldos> > mtdIngresarSaldo([FromBody] Saldos saldos)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();

                saldos.created_date       = horadeTransaccion.Value;
                saldos.last_modified_date = horadeTransaccion.Value;
                context.tbsaldo.Add(saldos);
                await context.SaveChangesAsync();

                return(Ok());
            }

            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
        public async Task <ActionResult> mtdActualizaTarjeta(int id, [FromBody] Tarjetas tarjetas)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();

                var response = await context.tbtarjetas.FirstOrDefaultAsync(x => x.id == id);

                if (response.id != id)
                {
                    return(BadRequest());
                }

                response.last_modified_by       = tarjetas.last_modified_by;
                response.last_modified_date     = horadeTransaccion.Value;
                response.bit_status             = tarjetas.bit_status;
                response.dc_mano_vigencia       = tarjetas.dc_mano_vigencia;
                response.dcm_mes_vigencia       = tarjetas.dcm_mes_vigencia;
                response.str_referencia_tarjeta = tarjetas.str_referencia_tarjeta;
                response.str_sistema_tarjeta    = tarjetas.str_sistema_tarjeta;
                response.str_tarjeta            = tarjetas.str_tarjeta;
                response.str_titular            = tarjetas.str_titular;
                response.int_id_usuario_id      = tarjetas.int_id_usuario_id;
                response.intidconcesion_id      = tarjetas.intidconcesion_id;

                await context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
        public async Task <ActionResult> mtdActualizaSaldos(int id, [FromBody] Saldos saldos)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();

                var response = await context.tbsaldo.FirstOrDefaultAsync(x => x.id == id);

                if (response.id != id)
                {
                    return(BadRequest());
                }

                response.last_modified_by     = saldos.last_modified_by;
                response.last_modified_date   = horadeTransaccion.Value;
                response.dtmfecha             = saldos.dtmfecha;
                response.flt_monto_final      = saldos.flt_monto_final;
                response.flt_monto_inicial    = saldos.flt_monto_inicial;
                response.int_id_usuario_trans = saldos.int_id_usuario_trans;
                response.str_forma_pago       = saldos.str_forma_pago;
                response.str_tipo_recarga     = saldos.str_tipo_recarga;
                response.int_id_usuario_id    = saldos.int_id_usuario_id;
                response.intidconcesion_id    = saldos.intidconcesion_id;

                await context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
        public async Task <ActionResult <ApplicationUser> > EditarUsuario([FromBody] UserInfo model, string id)
        {
            try
            {
                ParametrosController    par = new ParametrosController(context);
                ActionResult <DateTime> horadeTransaccion = par.mtdObtenerHora();
                var user = await _userManager.FindByIdAsync(id);


                if (user.Id != id)
                {
                    return(NotFound());
                }


                if (model.intidconcesion_id == 0)
                {
                    if (model.intidciudad == 0)
                    {
                        user.UserName           = model.UserName;
                        user.Email              = model.Email;
                        user.strNombre          = model.strNombre;
                        user.strApellidos       = model.strApellidos;
                        user.PhoneNumber        = model.PhoneNumber;
                        user.last_modified_by   = model.last_modified_by;
                        user.intidconcesion_id  = model.intidconcesion_id;
                        user.last_modified_date = horadeTransaccion.Value;
                        user.created_by         = model.created_by;
                        user.str_rfc            = model.str_rfc;
                        user.str_direccion      = model.str_direccion;
                        user.str_cp             = model.str_cp;
                        user.str_razon_social   = model.str_razon_social;
                        user.intidciudad        = null;
                        user.intidconcesion_id  = null;
                    }

                    user.UserName           = model.UserName;
                    user.Email              = model.Email;
                    user.strNombre          = model.strNombre;
                    user.strApellidos       = model.strApellidos;
                    user.PhoneNumber        = model.PhoneNumber;
                    user.last_modified_by   = model.last_modified_by;
                    user.intidconcesion_id  = model.intidconcesion_id;
                    user.last_modified_date = horadeTransaccion.Value;
                    user.created_by         = model.created_by;
                    user.str_rfc            = model.str_rfc;
                    user.str_direccion      = model.str_direccion;
                    user.str_cp             = model.str_cp;
                    user.str_razon_social   = model.str_razon_social;
                    user.intidciudad        = model.intidciudad;
                    user.intidconcesion_id  = null;
                }
                else
                {
                    user.UserName           = model.UserName;
                    user.Email              = model.Email;
                    user.strNombre          = model.strNombre;
                    user.strApellidos       = model.strApellidos;
                    user.PhoneNumber        = model.PhoneNumber;
                    user.last_modified_by   = model.last_modified_by;
                    user.intidconcesion_id  = model.intidconcesion_id;
                    user.last_modified_date = horadeTransaccion.Value;
                    user.created_by         = model.created_by;
                    user.str_rfc            = model.str_rfc;
                    user.str_direccion      = model.str_direccion;
                    user.str_cp             = model.str_cp;
                    user.str_razon_social   = model.str_razon_social;
                    user.intidciudad        = model.intidciudad;
                }


                var result = await _userManager.UpdateAsync(user);

                // await _userManager.RemoveFromRoleAsync(user, model.Rol);

                if (result.Succeeded)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }