コード例 #1
0
        public async Task <ActionResult> Edit([Bind(Include = "PersonId,FirstName,LastName,Email")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.Entry(person).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(person));
        }
コード例 #2
0
        public ActionResult Edit(ListViewModel model)
        {
            string timeToday    = DateTime.Now.ToString("h:mm:ss tt");
            string dateToday    = DateTime.Now.ToString("M/dd/yyyy");
            string text_details = Request.Form["text_details"];
            string check_public = Request.Form["check_public"];

            if (ModelState.IsValid)
            {
                using (var dbContext = new MvcDbContext())
                {
                    Lists list = dbContext.Lists.Find(model.Id);
                    list.Time_Edited            = timeToday;
                    list.Date_Edited            = dateToday;
                    list.Details                = text_details;
                    list.Public                 = check_public != null ? "YES" : "NO";
                    dbContext.Entry(list).State = EntityState.Modified;
                    dbContext.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(model));
        }