Example #1
0
        //Llamada al StoreProcedure que obtiene los datos para el reporte de Cancelación de Hipoteca
        public MortgageCancelReportData GetMortgageCancelByRequestId(Guid RequestId)
        {
            Model.Pocos.MortgageCancelReportData data = new Model.Pocos.MortgageCancelReportData();
            var        conexion = con.obtenConexion();
            SqlCommand command  = new SqlCommand("sp_getMortgageCancelByRequestId", conexion);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@RequestId", SqlDbType.UniqueIdentifier).Value = RequestId;

            try
            {
                conexion.Open();
                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        data.Name            = (string)reader["Name"];
                        data.City            = (string)reader["City"];
                        data.Date            = (DateTime)reader["Date"];
                        data.WritingProperty = (string)reader["WritingProperty"];
                        data.Telephone       = (string)reader["Telephone"];
                        data.MobileTelephone = (string)reader["MobilePhone"];
                    }
                }
                else
                {
                    Console.WriteLine("No rows found.");
                    return(null);
                }
                conexion.Close();
                return(data);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public async Task <DownloadFileResult> GetMortgageCancel(Guid RequestId)
        {
            try
            {
                //Llamar al método de consulta del store procedure que obtiene la información del request
                Hipotecas.Bussiness.MortgageBussiness BL    = new MortgageBussiness();
                Model.Pocos.MortgageCancelReportData  datos = BL.GetMortgageCancelByRequestId(RequestId);

                //convertimos la fecha obtenida para darle el formato requerido por el reporte
                string[] splitDate = datos.Date.ToLongDateString().Split(',');

                //Se asigna la información obtenida para generar el reporte
                MortgageCancel mortgage = new MortgageCancel()
                {
                    Name            = datos.Name.ToUpper(),
                    City            = datos.City.ToUpper(),
                    Date            = splitDate[1].ToUpper(),
                    Property        = datos.WritingProperty.ToUpper(),
                    Telephone       = datos.Telephone,
                    MobileTelephone = datos.MobileTelephone
                };

                DownloadFileResult result = null;
                var data = _mortgageReport.GetMortgageCancel(mortgage);
                result = new DownloadFileResult
                {
                    FileName = "CancelacionHipoteca.PDF",
                    Data     = data
                };
                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }