Exemplo n.º 1
0
        private SubscriptionGroupDescription UpdateSubscriptionGroup(SubscriptionGroupDescription subscriptionGroupDescription, string name, Guid uniqueKey)
        {
            using (var db = new Db.DataContext())
                using (var scope = db.CreateScope(System.Transactions.TransactionScopeOption.Suppress))
                {
                    var subscriptionGroupDb = db.SubscriptionGroup.Where(x => x.UniqueKey == uniqueKey).FirstOrDefault();
                    if (subscriptionGroupDb == null)
                    {
                        subscriptionGroupDb = new Db.SubscriptionGroup()
                        {
                            NameGroup = name,
                            UniqueKey = uniqueKey
                        };
                        db.SubscriptionGroup.Add(subscriptionGroupDb);
                        db.SaveChanges();
                    }

                    subscriptionGroupDb.NameGroup = name;
                    db.SaveChanges();

                    subscriptionGroupDescription.Id          = subscriptionGroupDb.IdGroup;
                    subscriptionGroupDescription.Name        = name;
                    subscriptionGroupDescription.IsConfirmed = true;
                    subscriptionGroupDescription.UniqueKey   = uniqueKey;
                }
            return(subscriptionGroupDescription);
        }
Exemplo n.º 2
0
 private SubscriptionGroupDescription CreateUnconfirmedSubscriptionGroupDescription(Db.SubscriptionGroup rowDb)
 {
     return(new SubscriptionGroupDescription
     {
         Id = rowDb.IdGroup,
         Name = rowDb.NameGroup,
         IsConfirmed = false,
         UniqueKey = rowDb.UniqueKey,
     });
 }