コード例 #1
0
        public void MiscTest()
        {
            ZigmaWebContext context = new ZigmaWebContext();

            context.Medias.ToList().ForEach(m => m.CreateDate = DateTime.Now);
            context.SaveChanges();
        }
コード例 #2
0
 public int SaveChanges()
 {
     return(_context.SaveChanges());
 }
        public static void Initialize()
        {
            var context = new ZigmaWebContext();

            #region Roles
            var role1 = new Role()
            {
                Name  = "admin",
                Title = "مدیر ارشد"
            };
            var role2 = new Role()
            {
                Name  = "moderator",
                Title = "مدیر"
            };
            context.Roles.AddRange(new Role[] { role1, role2 });
            #endregion

            #region Users
            var user1 = new User()
            {
                FirstName  = "مهرداد",
                LastName   = "تاجدینی",
                Email      = "*****@*****.**",
                Sexuality  = Sexuality.Male,
                Membership = new Membership()
                {
                    CreateDate = DateTime.Now,
                    FailedPasswordAttemptCount = 0,
                    IsApproved               = true,
                    IsLockedOut              = false,
                    Password                 = HashHelper.ComputeSha256Hash("12345"),
                    VerificationCode         = Guid.NewGuid(),
                    VerificationCodeSendDate = DateTime.Now
                },
            };
            user1.Roles.Add(role1);
            user1.Roles.Add(role2);
            user1.ProfileKeyValues.Add(new ProfileKeyValue()
            {
                Type = ProfileKeyValueType.AboutMe, Value = "This is me."
            });

            var user2 = new User()
            {
                FirstName  = "محمد",
                LastName   = "انصاری",
                Email      = "*****@*****.**",
                Sexuality  = Sexuality.Male,
                Membership = new Membership()
                {
                    CreateDate = DateTime.Now,
                    FailedPasswordAttemptCount = 0,
                    IsApproved               = true,
                    IsLockedOut              = false,
                    Password                 = HashHelper.ComputeSha256Hash("12345"),
                    VerificationCode         = Guid.NewGuid(),
                    VerificationCodeSendDate = DateTime.Now,
                },
            };
            user2.Roles.Add(role1);
            user2.Roles.Add(role2);
            user2.ProfileKeyValues.Add(new ProfileKeyValue()
            {
                Type = ProfileKeyValueType.AboutMe, Value = "This is me."
            });

            context.Users.AddRange(new User[] { user1, user2 });
            #endregion

            context.SaveChanges();
        }
コード例 #4
0
 public void SaveChanges()
 {
     _context.SaveChanges();
 }