예제 #1
0
        //Update
        public void Update(T item, Func <T, bool> findByIDPredecate)
        {
            var local = Context.Set <T>()
                        .Local
                        .FirstOrDefault(findByIDPredecate); // (f => f.ID == item.ID);

            if (local != null)
            {
                Context.Entry(local).State = EntityState.Detached;
            }

            Context.Entry(item).State = EntityState.Modified;

            Context.SaveChanges();
        }
        public IActionResult EditNote(int Id, string note)
        {
            UserPlanner found = _context.UserPlanner.Find(Id);

            if (ModelState.IsValid && note != null)
            {
                found.Notes = note;

                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.UserPlanner.Update(found);
                _context.SaveChanges();
                return(RedirectToAction("UserPlanner"));
            }
            else
            {
                return(RedirectToAction("UserPlanner"));
            }
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Id,Name")] EventType eventType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(eventType));
 }
예제 #4
0
 public ActionResult Edit([Bind(Include = "Id,ManafacturerId,Model,Caliber,Weight,BarrelLength,Price")] Weapon weapon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(weapon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ManafacturerId = new SelectList(db.Manafacturer, "Id", "Name", weapon.ManafacturerId);
     return(View(weapon));
 }
 public ActionResult Edit([Bind(Include = "Id,Title,Description,StartDate,StartTime,EndDate,EndTime,Location,OrganizerId,EventTypeId")] Event @event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@event).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EventTypeId = new SelectList(db.EventTypes, "Id", "Name", @event.EventTypeId);
     ViewBag.OrganizerId = new SelectList(db.Users, "Id", "FullName", @event.OrganizerId);
     return(View(@event));
 }
 public virtual async Task Update(TEntity entity)
 {
     _dbSet.Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
     await _context.SaveChangesAsync().ConfigureAwait(false);
 }