public void Save(Contracts.Model.AccommodationSupplier accommodationSupplier)
        {
            using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew,
                                                          new TransactionOptions
            {
                IsolationLevel = IsolationLevel.RepeatableRead
            }))
            {
                using (var context = new ContactEntities())
                {
                    var accSupplierToSave = context.AccommodationSuppliers.SingleOrDefault(
                        x => x.AccommodationSupplierId == accommodationSupplier.AccommodationSupplierId)
                                            ?? new AccommodationSupplier();

                    accSupplierToSave.AccommodationSupplierId = accommodationSupplier.AccommodationSupplierId;
                    accSupplierToSave.Name  = accommodationSupplier.Name;
                    accSupplierToSave.Email = accommodationSupplier.Email;

                    if (accSupplierToSave.Id == 0)
                    {
                        context.AccommodationSuppliers.Add(accSupplierToSave);
                    }

                    context.SaveChanges();
                    transaction.Complete();
                }
            }
        }
        public void Save(Contracts.Model.Authentication authentication)
        {
            using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew,
                                                          new TransactionOptions
            {
                IsolationLevel = IsolationLevel.RepeatableRead
            }))
            {
                using (var context = new ContactEntities())
                {
                    var authToSave = context.Authentications.SingleOrDefault(
                        x => x.AuthenticationId == authentication.AuthenticationId)
                                     ?? new Authentication();

                    authToSave.AuthenticationId = authentication.AuthenticationId;
                    authToSave.Email            = authentication.Email;
                    authToSave.HashedPassword   = authentication.HashedPassword;

                    if (authToSave.Id == 0)
                    {
                        context.Authentications.Add(authToSave);
                    }

                    context.SaveChanges();
                    transaction.Complete();
                }
            }
        }
        public void Save(Contracts.Model.User user)
        {
            using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew,
                                                          new TransactionOptions
            {
                IsolationLevel = IsolationLevel.RepeatableRead
            }))
            {
                using (var context = new ContactEntities())
                {
                    var userToSave = context.Users.SingleOrDefault(
                        x => x.UserId == user.UserId)
                                     ?? new User();

                    userToSave.UserId = user.UserId;
                    userToSave.Name   = user.Name;
                    userToSave.Email  = user.Email;

                    if (userToSave.Id == 0)
                    {
                        context.Users.Add(userToSave);
                    }

                    context.SaveChanges();
                    transaction.Complete();
                }
            }
        }