Exemple #1
0
 public UnitOfWork(MezbanAirKitchenEntities entities)
 {
     _context = entities;
     _context.Configuration.ProxyCreationEnabled = false;
     _repository = new Dictionary <Type, object>();
     _disposed   = false;
 }
Exemple #2
0
 public FormattedDbEntityValidationException(MezbanAirKitchenEntities context, DbEntityValidationException innerException) :
     base(null, innerException)
 {
     //Reload all entity
     foreach (var entry in context.ChangeTracker.Entries())
     {
         entry.Reload();
     }
 }
 public AspNetRoleRepository(MezbanAirKitchenEntities context) : base(context)
 {
 }
Exemple #4
0
 public ContentDefinitionRepository(MezbanAirKitchenEntities context) : base(context)
 {
 }
 public ContentEntryRepository(MezbanAirKitchenEntities context) : base(context)
 {
 }
 public RestaurantRepository(MezbanAirKitchenEntities context) : base(context)
 {
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public BaseRepository(MezbanAirKitchenEntities context)
 {
     _dbContext = context;
     _dbContext.Configuration.ProxyCreationEnabled = false;
     Dbset = context.Set <T>();
 }
Exemple #8
0
 public LanguageRepository(MezbanAirKitchenEntities context) : base(context)
 {
 }
Exemple #9
0
        private void CreateRolesAndUsers()
        {
            ApplicationDbContext context = new ApplicationDbContext();

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            // In Startup iam creating first Admin Role and creating a default Admin User
            if (!roleManager.RoleExists("Admin"))
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole {
                    Name = "Admin"
                };
                roleManager.Create(role);
                var person = new Person
                {
                    PersonId  = Guid.NewGuid(),
                    FisrtName = "Minh",
                    LastName  = "Hieu"
                };
                using (var db = new MezbanAirKitchenEntities())
                {
                    db.Persons.Add(person);
                    db.SaveChanges();
                };
                var user = new ApplicationUser
                {
                    UserName = "******",
                    Email    = "*****@*****.**",
                    PersonId = person.PersonId
                };

                string userPWD = "Admin@321";

                var chkUser = userManager.Create(user, userPWD);

                //Add default User to Role Admin
                if (chkUser.Succeeded)
                {
                    var result1 = userManager.AddToRole(user.Id, "Admin");
                }
            }

            // creating Creating Manager role
            if (!roleManager.RoleExists("Owner"))
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole {
                    Name = "Owner"
                };
                roleManager.Create(role);
            }

            // creating Creating Employee role
            if (!roleManager.RoleExists("Employee"))
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole {
                    Name = "Employee"
                };
                roleManager.Create(role);
            }
        }