// GET api/correo/correoelectrónico
        // Retrieve by id
        public IHttpActionResult Get(string id)
        {
            try
            {
                var mngS = new SolicitudHotelCrudFactory();

                var solicitudHotel = new SolicitudHotel
                {
                    CodigoSolicitud = Convert.ToInt32(id)
                };
                SolicitudHotel c = null;
                c = mngS.Retrieve <SolicitudHotel>(solicitudHotel);

                if (c != null)
                {
                    //solicitudHotel = mngS.RetrieveById(solicitudHotel);
                    var respuesta = "correo está comentado";
                    //var respuesta = EnviarCorreoManager.GetInstance().Enviar(c.CorreoUsuario, "RegistroHotel", c);

                    apiResp.Data = respuesta;
                    return(Ok(apiResp));
                }
                else
                {
                    apiResp.Data = "solicitud no existe";
                    return(Ok(apiResp));
                }
            }
            catch (Exception ex)
            {
                apiResp.Data = ex.Message;
                return(Ok(apiResp));
            }
        }
Exemplo n.º 2
0
        public async Task UpdateAsync(SolicitudHotel solicitudHotel)
        {
            //valores a modificar
            var     estadoCambio = solicitudHotel.Estado;
            decimal membrecia    = 0;

            if (solicitudHotel.Membrecia > 0)
            {
                membrecia = solicitudHotel.Membrecia;
            }

            var hotelEnviado = new SolicitudHotel
            {
                CodigoSolicitud = solicitudHotel.CodigoSolicitud
            };



            SolicitudHotel c = null;

            c = crudSolicitudHotel.Retrieve <SolicitudHotel>(hotelEnviado);



            if (c != null)//si la solicitud del id existe quiero que le cambie el estado
            {
                if (estadoCambio.Equals("Aprobada"))
                {
                    if (c.Estado.Equals("Pendiente"))
                    {
                        c.Estado    = "Aprobada";
                        c.Membrecia = membrecia;
                        var respuesta = await EnviarCorreoManager.GetInstance().ExecuteCorreoSolicitudAprobada(c.CorreoUsuario, c);
                    }
                }
                else if (estadoCambio.Equals("Rechazada"))
                {
                    if (c.Estado.Equals("Pendiente"))
                    {
                        c.Estado    = "Rechazada";
                        c.Membrecia = 0;

                        var respuesta = await EnviarCorreoManager.GetInstance().ExecuteCorreoSolicitudRechazada(c.CorreoUsuario, c);
                    }
                }
                else
                {
                }
                crudSolicitudHotel.Update(c);
            }
            else
            {
                throw new BussinessException(55);
            }
        }
Exemplo n.º 3
0
        public void UpdateEstado(string IdSoliYEstado)
        {
            var datos     = IdSoliYEstado.Split(',');
            var id        = 0;
            int numCodigo = -1;

            if (Int32.TryParse(datos[0], out numCodigo))
            {
                id = numCodigo;
            }
            else
            {
                throw new BussinessException(56);
            }

            var estadoCambio = datos[1];

            var hotelEnviado = new SolicitudHotel
            {
                CodigoSolicitud = id
            };


            SolicitudHotel c = null;

            c = crudSolicitudHotel.Retrieve <SolicitudHotel>(hotelEnviado);


            if (c != null)//si la solicitud del id existe quiero que le cambie el estado
            {
                if (estadoCambio.Equals("Aprobado"))
                {
                    if (c.Estado.Equals("Pendiente"))
                    {
                        c.Estado = "Aprobado";
                    }
                }
                else if (estadoCambio.Equals("Rechazado"))
                {
                    if (c.Estado.Equals("Pendiente"))
                    {
                        c.Estado = "Rechazado";
                    }
                }
                else
                {
                }
                crudSolicitudHotel.Update(c);
            }
            else
            {
                throw new BussinessException(55);
            }
        }
Exemplo n.º 4
0
        public SolicitudHotel RetrieveById(SolicitudHotel solicitudHotel)
        {
            SolicitudHotel c = null;

            try
            {
                c = crudSolicitudHotel.Retrieve <SolicitudHotel>(solicitudHotel);
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }

            return(c);
        }
        // PUT
        // UPDATE
        public async Task <IHttpActionResult> PutAsync(SolicitudHotel solicitudHotel)
        {
            try
            {
                var mng = new SolicitudHotelManager();
                await mng.UpdateAsync(solicitudHotel);

                apiResp         = new ApiResponse();
                apiResp.Message = "Solicitud resuelta con éxito";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
        //[HttpPut]
        //public IHttpActionResult PutEstado(string id)
        //{
        //    try
        //    {
        //        apiResp = new ApiResponse();
        //        var mng = new SolicitudHotelManager();

        //        mng.UpdateEstado(id);

        //        apiResp.Message = "Estado modificado";

        //        return Ok(apiResp);

        //    }
        //    catch (Exception ex)
        //    {
        //        return Ok(ex.Data);
        //    }
        //}

        // DELETE ==
        public IHttpActionResult Delete(SolicitudHotel solicitudHotel)
        {
            try
            {
                var mng = new SolicitudHotelManager();
                mng.Delete(solicitudHotel);

                apiResp         = new ApiResponse();
                apiResp.Message = "Acción ejecucada con éxito";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
        // GET api/solicitudHotel/5
        // Retrieve by id
        public IHttpActionResult Get(string id)
        {
            try
            {
                var mng            = new SolicitudHotelManager();
                var solicitudHotel = new SolicitudHotel();
                apiResp = new ApiResponse();

                var numCodigo = 0;
                if (Int32.TryParse(id, out numCodigo))
                {
                    solicitudHotel = new SolicitudHotel
                    {
                        CodigoSolicitud = numCodigo
                    };
                }
                else
                {
                    apiResp.Data    = null;
                    apiResp.Message = "codigo de solcitud incorrecto";
                    return(Ok(apiResp));
                };



                solicitudHotel = mng.RetrieveById(solicitudHotel);

                if (solicitudHotel != null)
                {
                    apiResp.Data    = solicitudHotel;
                    apiResp.Message = "Solicitud retornado";
                }
                else
                {
                    apiResp.Message = "No existe";
                }


                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
        // POST
        // CREATE
        public IHttpActionResult Post(SolicitudHotel solicitudHotel)
        {
            try
            {
                var mng = new SolicitudHotelManager();


                mng.Create(solicitudHotel);
                apiResp         = new ApiResponse();
                apiResp.Message = "Solicitud enviada con éxito, recibirá un correo electrónico cuando la solicitud haya sido aprobada";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
Exemplo n.º 9
0
        public Entity BuildObject(Dictionary <string, object> row)
        {
            var solicitudHotel = new SolicitudHotel
            {
                CodigoSolicitud = GetIntValue(row, DB_COL_CODIGO_SOLICITUD),
                Nombre          = GetStringValue(row, DB_COL_NOMBRE),
                CedulaJuridica  = GetStringValue(row, DB_COL_CEDULA_JURIDICA),
                EmpresaDuenna   = GetStringValue(row, DB_COL_EMPRESA_DUENNA),
                Direccion       = GetStringValue(row, DB_COL_DIRECCION),
                Descripcion     = GetStringValue(row, DB_COL_DESCRIPCION),
                Cadena          = GetStringValue(row, DB_COL_CADENA),
                Clasificacion   = GetIntValue(row, DB_COL_CLASIFICACION),
                Estado          = GetStringValue(row, DB_COL_ESTADO),
                IdUsuario       = GetStringValue(row, DB_COL_ID_USUARIO),
                CorreoUsuario   = GetStringValue(row, DB_COL_CORREO_USUARIO),
                NombreUsuario   = GetStringValue(row, DB_COL_NOMBRE_USUARIO),
                Membrecia       = GetDoubleValue(row, DB_COL_MEMBRECIA)
            };

            return(solicitudHotel);
        }
Exemplo n.º 10
0
        public void Create(SolicitudHotel solicitudHotel)
        {
            try
            {
                solicitudHotel.Estado = "Pendiente";

                if (solicitudHotel.Cadena == null)
                {
                    solicitudHotel.Cadena = "";
                }

                var c = crudSolicitudHotel.Retrieve <SolicitudHotel>(solicitudHotel);
                if (c != null)
                {
                    //solicitud already exist
                    throw new BussinessException(54);
                }
                else
                {
                    Hotel hotel = new Hotel
                    {
                        CedulaJuridica = solicitudHotel.CedulaJuridica
                    };

                    var d = crudHotel.Retrieve <Hotel>(hotel);
                    if (d != null)
                    {
                        throw new BussinessException(52);
                    }
                    else
                    {
                        crudSolicitudHotel.Create(solicitudHotel);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }
        }
Exemplo n.º 11
0
 public void Delete(SolicitudHotel solicitudHotel)
 {
     crudSolicitudHotel.Delete(solicitudHotel);
 }