Exemplo n.º 1
0
                                                      public HttpResponseMessage GetFileCurso(long id) //id del Adjunto
                                                      {
                                                          var localFilePath = "";
                                                          var nombre        = "download";

                                                          try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                AdjuntoCursosRepository _adjunto;
                                                                _adjunto = new AdjuntoCursosRepository();
                                                                AdjuntoCursos fil = _adjunto.Get(id);
                                                                localFilePath = fil.RutaCompleta;
                                                                nombre        = fil.nombre;


                                                                UtileriasArchivo util = new UtileriasArchivo();
                                                                return(util.GetFile(localFilePath, nombre, Request)); }
                                                          catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message + " (" + nombre + ")")); }
                                                      }
Exemplo n.º 2
0
                                                      public async Task <IHttpActionResult> GetDatosCursos(long id)
                                                      {
                                                          try{ log.Info(new MDCSet(this.ControllerContext.RouteData), new InfoException(id));
                                                               AdjuntoCursosRepository _adjunto;
                                                               _adjunto = new AdjuntoCursosRepository();
                                                               var fil = await _adjunto.GetAsync(id);

                                                               var mime = UtilMime.GetMimeMapping(fil.nombre);
                                                               var obj  = new
                                                               {
                                                                   nombre = fil.nombre,
                                                                   mime   = mime
                                                               };
                                                               return(Ok(obj)); }
                                                          catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                return(InternalServerError(e)); }
                                                      }
 public AdjuntoCursosController()
 {
     _repository = new AdjuntoCursosRepository();
 }