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")); } }
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"); }
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()); } }
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)); }