예제 #1
0
 // GET: ReceiveEmail/Create
 public ActionResult Create(ReceiveEmail model, int pageNo = 1)
 {
     if (ModelState.IsValid)
     {
         db.ReceiveEmails.Add(model);
         db.SaveChanges();
     }
     return(RedirectToAction("Index", new { PageNo = pageNo }));
 }
예제 #2
0
        public ActionResult Index(int pageNo = 1, int id = 0, string searchString = "")
        {
            //Search
            var reEmail = from a in db.ReceiveEmails
                          select a;

            if (!String.IsNullOrEmpty(searchString))
            {
                reEmail = reEmail.Where(a => a.Name.Contains(searchString));
            }
            //End Search

            var model = new ReceiveEmail();

            if (id > 0)
            {
                model = db.ReceiveEmails.Find(id);
            }

            //truyền reEmail vào BindList
            BindList(pageNo, reEmail.ToList());
            return(View(model));
        }
예제 #3
0
 // GET: ReceiveEmail/Edit/5
 public ActionResult Edit(ReceiveEmail model, int pageNo = 1)
 {
     db.Entry(model).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index", new { PageNo = pageNo }));
 }