Exemplo n.º 1
0
        private static void CreateDummyUsers(int NumOfUsers)
        {
            Role lDummyRole = new Role() { Name = "User" };
            using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
            {
                if (lContainer.Users.Count() > NumOfUsers + 1)
                {
                    return;
                }
            }
            for (int i = 0; i < NumOfUsers; i++ )
            {

                User pUser = new User()
                {
                    Name = lDummyRole.Name + i.ToString(),
                    LoginCredential = new LoginCredential() { UserName = lDummyRole.Name + i.ToString(), Password = "******" },
                    Email = lDummyRole.Name + i.ToString() + "@Dummy.com",
                    Address = "1 Central Park"
                };

                pUser.Roles.Add(lDummyRole);

                ServiceLocator.Current.GetInstance<IUserProvider>().CreateUser(pUser);
            }
        }
Exemplo n.º 2
0
 public void DeleteUser(User pUser)
 {
     using(TransactionScope lScope = new TransactionScope())
     using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
     {
         lContainer.Users.DeleteObject(pUser);
         lContainer.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void CreateUser(VideoStore.Business.Entities.User pUser)
 {
     using (TransactionScope lScope = new TransactionScope())
         using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
         {
             lContainer.Users.AddObject(pUser);
             lContainer.SaveChanges();
             lScope.Complete();
         }
 }
Exemplo n.º 4
0
 public void UpdateUser(User pUser)
 {
     using(TransactionScope lScope = new TransactionScope())
     using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
     {
         lContainer.Users.Attach(pUser);
         lContainer.ObjectStateManager.ChangeObjectState(pUser, System.Data.EntityState.Modified);
         lContainer.SaveChanges();
         lScope.Complete();
     }
 }
Exemplo n.º 5
0
 public bool IsMediaLikedByUser(Media pMedia, User pUser)
 {
     //get the medias this user liked before
     List<Media> mList = this.GetMediumUserLikes(pUser.Id);
     bool b =  false;
     foreach(Media m in mList){
         if (m.Id == pMedia.Id) {
             b = true;
         }
     }
     return b;
 }
Exemplo n.º 6
0
        private static void CreateUser()
        {
            using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
            {
                if (lContainer.Users.Where((pUser) => pUser.Name == "Customer").Count() > 0)
                    return;
            }
            User lCustomer = new User()
            {
                Name = "Customer",
                LoginCredential = new LoginCredential() { UserName = "******", Password = "******" },
                Email = "*****@*****.**",
                Address = "1 Central Park",
                BankAccountNumber = 456,
            };

            ServiceLocator.Current.GetInstance<IUserProvider>().CreateUser(lCustomer);
        }
Exemplo n.º 7
0
        private static void CreateOperator()
        {
            Role lOperatorRole = new Role() { Name = "Operator" };
            using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
            {
                if (lContainer.Roles.Count() > 0)
                {
                    return;
                }
            }
            User lOperator = new User()
            {
                Name = "Operator",
                LoginCredential = new LoginCredential() { UserName = "******", Password = "******" },
                Email = "*****@*****.**",
                Address = "1 Central Park"
            };

            lOperator.Roles.Add(lOperatorRole);

            ServiceLocator.Current.GetInstance<IUserProvider>().CreateUser(lOperator);
        }
Exemplo n.º 8
0
 public void UpdateUser(User pUser)
 {
     pUser.Address = this.Address;
     pUser.Email = this.Email;
     UserService.UpdateUser(pUser);
 }
Exemplo n.º 9
0
 public UserViewModel(User pUser)
 {
     Address = pUser.Address;
     Email = pUser.Email;
 }
Exemplo n.º 10
0
 public void UpdateUserCache()
 {
     Model = new UserServiceClient().ReadUserById(Model.Id);
 }
Exemplo n.º 11
0
 public UserCache(User pModel)
 {
     Model = pModel;
 }
Exemplo n.º 12
0
        private void FixupCustomer(User previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.Orders.Contains(this))
            {
                previousValue.Orders.Remove(this);
            }

            if (Customer != null)
            {
                if (!Customer.Orders.Contains(this))
                {
                    Customer.Orders.Add(this);
                }

            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Customer")
                    && (ChangeTracker.OriginalValues["Customer"] == Customer))
                {
                    ChangeTracker.OriginalValues.Remove("Customer");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Customer", previousValue);
                }
                if (Customer != null && !Customer.ChangeTracker.ChangeTrackingEnabled)
                {
                    Customer.StartTracking();
                }
                FixupCustomerKeys();
            }
        }
Exemplo n.º 13
0
 public bool IsMediaLikedByUser(Media pMedia,User pUser)
 {
     return CatalogueProvider.IsMediaLikedByUser(pMedia,pUser);
 }
Exemplo n.º 14
0
     private void FixupUsers(User previousValue)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.Review.Contains(this))
         {
             previousValue.Review.Remove(this);
         }
 
         if (Users != null)
         {
             if (!Users.Review.Contains(this))
             {
                 Users.Review.Add(this);
             }
 
         }
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Users")
                 && (ChangeTracker.OriginalValues["Users"] == Users))
             {
                 ChangeTracker.OriginalValues.Remove("Users");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Users", previousValue);
             }
             if (Users != null && !Users.ChangeTracker.ChangeTrackingEnabled)
             {
                 Users.StartTracking();
             }
             FixupUsersKeys();
         }
     }
Exemplo n.º 15
0
 public static void CreateUser(User pUser)
 {
     UserServiceClient.CreateUser(pUser);
 }
Exemplo n.º 16
0
 public static System.Web.Security.MembershipUser CreateUser(this System.Web.Security.MembershipProvider pProvider, String pUserName, String pPassword, String pPostalAddress, String pEmail, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status)
 {
     try
     {
         User lUser = new User() { Address = pPostalAddress, Name = pUserName, LoginCredential = new LoginCredential() { UserName = pUserName, Password = pPassword }, Email = pEmail };
         MembershipProvider.CreateUser(lUser);
         status = MembershipCreateStatus.Success;
     }
     catch (Exception)
     {
         status = MembershipCreateStatus.ProviderError;
     }
     return new MembershipUser("VideoStoreMembershipProvider", pUserName, null, pEmail, null, null, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.MinValue);
 }