コード例 #1
0
 public ActionResult New(tUser user)
 {
     if (user == null)
     {
         return(View("New"));
     }
     else
     {
         dbAlbumDemoEntities db = new dbAlbumDemoEntities();
         db.tUser.Add(user);
         db.SaveChanges();
         return(View("Login"));
     }
 }
コード例 #2
0
        public ActionResult Upload(tAlbum t,HttpPostedFileBase photo)
        {
            if ((t == null)|(photo==null))
                Response.Redirect("Upload");
            
            dbAlbumDemoEntities db = new dbAlbumDemoEntities();
            string photoname = Guid.NewGuid().ToString() + ".jpg";
            t.fPath = "../Content/img/" + photoname;
            photo.SaveAs(Server.MapPath("../Content/img/" + photoname));

            db.tAlbum.Add(t);
            db.SaveChanges();

            return View("../Home/Index");
        }
コード例 #3
0
        public ActionResult Login(string acNum, string pwd)
        {
            dbAlbumDemoEntities db = new dbAlbumDemoEntities();
            tUser u = db.tUser.FirstOrDefault(
                t => t.fAcountName.Equals(acNum) && t.fPassword.Equals(pwd));

            if (u != null)
            {
                Session[CDictionary.LOGIN_USER] = u;
                return(View("../Upload/Upload"));
            }
            else
            {
                ViewBag.WrongMessage = "Wrong Account Number or Wrong Password";
                return(View());
            }
        }
コード例 #4
0
        public ActionResult Home(int page = 1)
        {
            if (Session[CDictionary.LOGIN_USER] != null)
            {
                tUser t = Session[CDictionary.LOGIN_USER] as tUser;
                ViewBag.User = "******" + t.fUserName + " [" + t.fMail + "]";
            }
            else
            {
                ViewBag.User = "******";
            }

            int pagesize           = 3;
            int currentpage        = pagesize < 1 ? 1 : page;
            dbAlbumDemoEntities db = new dbAlbumDemoEntities();
            var all = from t in db.tAlbum
                      orderby t.fId ascending
                      select t;
            var pagelist = all.ToPagedList(currentpage, pagesize);

            return(View(pagelist));
        }