Exemplo n.º 1
0
        // GET: Persona
        public ActionResult Listar()
        {
            var model = new PersonaModel();

            using (var db = new dbTestEntities())
            {
                model.ObjetoPersona = db.Persona.FirstOrDefault();
            }


            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult upload(tUpload u)
        {
            //若上傳檔案超出最大限制(4mb),到Web.config的<system.web>標籤內的<httpRuntime>標籤添加新的屬性↓
            //maxRequestLength="想更改的長度限制",單位是KB

            //string name = Path.GetFileName(u.file.FileName) + ".png";
            string name = Guid.NewGuid().ToString() + ".mp3";
            var    path = Path.Combine(Server.MapPath("~/Music"), name);


            u.file.SaveAs(path);
            u.fDate = DateTime.Now;
            u.fPath = "/Music/" + name;
            dbTestEntities db = new dbTestEntities();

            db.tUpload.Add(u);
            db.SaveChanges();
            return(View());
        }