public void Save()
        {
            var pick = ToPick();

            using (var db = new PicksDb())
            {
                db.Entry(pick).State = (Id == 0) ? EntityState.Added : EntityState.Modified;

                db.SaveChanges();
            }
        }
Exemple #2
0
        public static void DeleteForUser(string userId)
        {
            var picks = PickViewModel.GetListForUser(userId, null);
            using (var db = new PicksDb())
            {
                foreach (var pick in picks)
                {
                    var p = pick.ToPick();

                    db.Entry(p).State = EntityState.Deleted;
                }
                db.SaveChanges();
            }
        }