Inheritance: IUnitOfWork
Example #1
0
 public UserAccount()
 {
     _uow = new UnitOfWork<UsersAccountContext>();
     _user = new UserProfileRepository(_uow);
     _roles = new webpages_RolesRepository(_uow);
     _inRoles = new webpages_UsersInRolesRepository(_uow);
 }
        public void TestMethod1()
        {
            using (SchoolContext ctx = new SchoolContext())
            {
                ctx.Configuration.LazyLoadingEnabled = false;
                //School s1 = new School() { Name = "Coopers", Address = "Royal Parade" };
                //EntityState st1 = ctx.Entry(s1).State;
                //ctx.Schools.Add(s1);

                //ctx.SaveChanges();

                School s2 = ctx.Schools.Include(x => x.Students).Where(x => x.Id == 1).FirstOrDefault();

                EntityState st2 = ctx.Entry(s2).State;
                s2.Name = "change";
                st2 = ctx.Entry(s2).State;
            }

            using (UnitOfWork uow = new UnitOfWork())
            {
                School s1 = uow.Repository<School>().GetByID(1);

                uow.Repository<School>().Insert(new School() { Name = "Coopers", Address = "Royal Parade" });
                uow.Save();
            }
        }
Example #3
0
 public BaseController()
 {
     uOW = new UnitOfWork();
     userManager = new UserManager(uOW);
     carManager = new CarManager(uOW);
     districtManager = new DistrictManager(uOW);
     personManager = new PersonManager(uOW);
     locationManager = new LocationManager(uOW);
     tarifManager = new TarifManager(uOW);
 }
Example #4
0
        static void Main(string[] args)
        {
            DbContext context = new EntityContext();
            var uow = new UnitOfWork(context);

            var userservice = new UserService(uow, new UserRepository(context));
            var roleservice = new RoleService(uow, new RoleRepository(context));
            var pictureService = new PictureService(uow, new PictureRepository(context));
            var picProfileService = new PictureProfileService(uow, new PictureProfileRepository(context));

            var user = userservice.GetUserEntity("super_admin");
            //userservice.DeleteUser(user);
            roleservice.AddUserToRole("admin", user.Id);

            File.WriteAllLines("users.txt", new string[] { user.Username, user.Salt, user.Password, user.Email});
        }
 public StudentService(UnitOfWork unitOfWork)
     : base(unitOfWork)
 {
 }
 public BaseService(UnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
 public ReportService()
 {
     _uow = new UnitOfWork<ReportServiceContext>();
     _order = new OrdersRepository(_uow);
 }
 public Repository(UnitOfWork unitOfWork)
 {
     this.unitOfWork = unitOfWork;
 }
 public BaseController()
 {
     _unitOfWork = new UnitOfWork(new SchoolContext());
     StudentService = new StudentService(_unitOfWork);
     LINQExamplesService = new LINQExamplesService(_unitOfWork);
 }