Esempio n. 1
0
        // GET: Formatos
        public ActionResult Formatos(Formatos obj, HttpPostedFileBase file)
        {
            Plataforma_academica.Models.principalP act2 = Session["usuario12"] as Plataforma_academica.Models.principalP;
            Login user = Session["usuario"] as Login;

            if (user == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                if (Convert.ToInt32(user.rol) != 4)
                {
                    String codigo1 = Request.Form["seccion"];
                    if (codigo1 != null)
                    {
                        if (obj.Registrar_formato(Subir(file), nombre, Convert.ToInt32(user.usuario)))
                        {
                            ViewBag.mensaje = "Exito al cargar";
                            return(View());
                        }
                        else
                        {
                            ViewBag.mensaje = "Fallo cargue";
                        }
                    }
                    String codigo_ = Request.Form["subir"];
                    if (codigo_ != null)
                    {
                        var ruta = Server.MapPath("~/imagen_multimedia/" + codigo_);
                        return(File(ruta, "aplication/pdf,docx", codigo_));
                    }
                    return(View());
                }
                else
                {
                    return(RedirectToAction("PrincipalPlataforma", "principalplataforma"));
                }
            }
        }