public void Modify(Base model, ApplicationDbContext db)
        {
            ModifyTime = DateTime.Now;
            Name = model.Name;
            Description = model.Description;

            db.Entry(this).State = EntityState.Modified;
        }
 public override void Create(ApplicationDbContext db)
 {
     base.Create(db);
     if (Awards != null)
     {
         foreach (var item in Awards)
         {
             db.Entry(item).State = EntityState.Unchanged;
         }
     }
 }
        public void Modify(Activity model, ApplicationDbContext db)
        {
            base.Modify(model, db);
            CoverUrl = model.CoverUrl;
            BeginTime = model.BeginTime;
            EndTime = model.EndTime;
            Count = model.Count;

            model.Awards = model.Awards ?? new List<Award>();

            var add = model.Awards.Where(o1 => !Awards.Any(o2 => o1.Id == o2.Id)).ToList();
            var remove = Awards.Where(o1 => !model.Awards.Any(o2 => o1.Id == o2.Id)).ToList();

            foreach (var item in add)
            {
                db.Entry(item).State = EntityState.Unchanged;
                Awards.Add(item);
            }

            foreach (var item in remove)
            {
                Awards.Remove(item);
            }
        }