Esempio n. 1
0
        static async Task Main(string[] args)
        {
            //This is for demo porpouses, use dependecy injection in a real project...
            SampleDataContext context = new SampleDataContext();

            //**************************************************************************************
            //Here you see how the same generic repo can be used for distinct entities...
            GenericRepo <Customer> customersRepo = new GenericRepo <Customer>(context);
            GenericRepo <Order>    ordersRepo    = new GenericRepo <Order>(context);
            GenericRepo <Invoice>  invoicesRepo  = new GenericRepo <Invoice>(context);
            //**************************************************************************************

            Customer customer = new Customer()
            {
                FirstName = "Jhon"
            };

            await customersRepo.AddAsync(customer);

            await customersRepo.SaveAsync();

            List <Customer> customers = new List <Customer>();

            customers = await customersRepo.GetAllAsync();

            foreach (var cust in customers)
            {
                Console.WriteLine($"Customer name: {cust.FirstName}");
            }

            Console.ReadLine();
        }
Esempio n. 2
0
 public FolderService(GenericRepo <Katalog> folderRepo, IFilesService filesService,
                      GenericRepo <Plik> fileRepo)
 {
     _folderRepo  = folderRepo;
     _fileService = filesService;
     _fileRepo    = fileRepo;
 }
        public void CanAddParentAndChild()
        {
            string name = "Ben";
            GenericRepo <Customer> customerRepo = new GenericRepo <Customer>();

            customerRepo.Add(new Customer
            {
                Name   = name,
                Orders = new List <Order> {
                    new Order {
                        Name = "Order 1"
                    },
                    new Order {
                        Name = "Order 2"
                    }
                }
            });

            Customer customer = new Customer();

            using (var context = new GenericRepoContext())
            {
                customer = context.Customers.Where(x => x.Name == name)
                           .Include(x => x.Orders).SingleOrDefault();
            }

            Assert.AreEqual(2, customer.Orders.Count);
        }
Esempio n. 4
0
        internal CONTACT Get()
        {
            using (entity = new klassycafeEntities())
            {
                ContactRepo = new GenericRepo <CONTACT>(entity);
                int CONTACTCount = ContactRepo.Select().Count();
                if (CONTACTCount <= 0)
                {
                    ContactRepo.Insert(new CONTACT()
                    {
                        EMAIL     = "",
                        PHONE     = "",
                        FACEBOOK  = "",
                        INSTAGRAM = "",
                        LINKEDIN  = "",
                        TWITTER   = ""
                    });
                    ContactRepo.Save();

                    return(ContactRepo.Select().ToList()[0]);
                }
                else
                {
                    return(ContactRepo.Select().ToList()[0]);
                }
            }
        }
Esempio n. 5
0
        internal List <RESERVATIONLIST> GetTodayList()
        {
            DateTime startDateTime = DateTime.Today;
            DateTime endDateTime   = DateTime.Today.AddDays(1).AddTicks(-1);

            using (entity = new klassycafeEntities())
            {
                reservationRepo = new GenericRepo <RESERVATION>(entity);
                stateRepo       = new GenericRepo <RESERVATIONSTATE>(entity);

                List <RESERVATION>     rs    = reservationRepo.Select(r => r.RESERVATION_DATE >= startDateTime && r.RESERVATION_DATE <= endDateTime).ToList();
                List <RESERVATIONLIST> rList = new List <RESERVATIONLIST>();

                foreach (RESERVATION r in rs)
                {
                    rList.Add(new RESERVATIONLIST()
                    {
                        reservation          = r,
                        reservationStateName = stateRepo.FindByID(r.RESERVATIONSTATE_ID).NAME
                    });
                }

                return(rList);
            }
        }
Esempio n. 6
0
 public RegisterService(UserManager <SystemUser> userManager, GenericRepo <Zolnierz> zolnierzRepo,
                        UserService userService)
 {
     _userManager  = userManager;
     _zolnierzRepo = zolnierzRepo;
     _userService  = userService;
 }
Esempio n. 7
0
 internal RESERVATION GetById(int id)
 {
     using (entity = new klassycafeEntities())
     {
         reservationRepo = new GenericRepo <RESERVATION>(entity);
         return(reservationRepo.FindByID(id));
     }
 }
 internal List <MENUCATEGORY> GetActives()
 {
     using (entity = new klassycafeEntities())
     {
         menuCategoryRepo = new GenericRepo <MENUCATEGORY>(entity);
         return(menuCategoryRepo.Select(mc => mc.STATE_ID == 1).ToList());
     }
 }
Esempio n. 9
0
 internal MENUITEM GetById(int id)
 {
     using (entity = new klassycafeEntities())
     {
         menuItemRepo = new GenericRepo <MENUITEM>(entity);
         return(menuItemRepo.FindByID(id));
     }
 }
Esempio n. 10
0
 internal List <MENUITEM> GetActives()
 {
     using (entity = new klassycafeEntities())
     {
         menuItemRepo = new GenericRepo <MENUITEM>(entity);
         return(menuItemRepo.Select(mc => mc.STATE_ID == 1).ToList());
     }
 }
Esempio n. 11
0
 internal List <STATE> GetAll()
 {
     using (entity = new klassycafeEntities())
     {
         stateRepo = new GenericRepo <STATE>(entity);
         return(stateRepo.Select().ToList());
     }
 }
Esempio n. 12
0
 internal List <CHEF> GetActives()
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         return(chefRepo.Select(c => c.STATE_ID == 1).ToList());
     }
 }
Esempio n. 13
0
 internal List <MENUITEM> GetForMenuSlider()
 {
     using (entity = new klassycafeEntities())
     {
         menuItemRepo = new GenericRepo <MENUITEM>(entity);
         return(menuItemRepo.Select(mc => mc.STATE_ID == 1 && (bool)mc.MENUSLIDER_SHOW).ToList());
     }
 }
Esempio n. 14
0
 internal CHEF GetById(int id)
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         return(chefRepo.FindByID(id));
     }
 }
Esempio n. 15
0
 internal List <CHEF> GetAll()
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         return(chefRepo.Select().ToList());
     }
 }
Esempio n. 16
0
 internal USER GetByEmail(string email)
 {
     using (entity = new klassycafeEntities())
     {
         userRepo = new GenericRepo <USER>(entity);
         return(userRepo.FindByLambda(u => u.EMAIL == email));
     }
 }
Esempio n. 17
0
 internal void Remove(int id)
 {
     using (entity = new klassycafeEntities())
     {
         menuItemRepo = new GenericRepo <MENUITEM>(entity);
         menuItemRepo.Delete(id);
         menuItemRepo.Save();
     }
 }
Esempio n. 18
0
 internal void Update(CONTACT CONTACT)
 {
     using (entity = new klassycafeEntities())
     {
         ContactRepo = new GenericRepo <CONTACT>(entity);
         ContactRepo.Update(CONTACT);
         ContactRepo.Save();
     }
 }
Esempio n. 19
0
 internal void Add(MENUITEM menuitem)
 {
     using (entity = new klassycafeEntities())
     {
         menuItemRepo = new GenericRepo <MENUITEM>(entity);
         menuItemRepo.Insert(menuitem);
         menuItemRepo.Save();
     }
 }
Esempio n. 20
0
 internal void Edit(MENUITEM menuitem)
 {
     using (entity = new klassycafeEntities())
     {
         menuItemRepo = new GenericRepo <MENUITEM>(entity);
         menuItemRepo.Update(menuitem);
         menuItemRepo.Save();
     }
 }
Esempio n. 21
0
 internal void Edit(RESERVATION reservation)
 {
     using (entity = new klassycafeEntities())
     {
         reservationRepo = new GenericRepo <RESERVATION>(entity);
         reservationRepo.Update(reservation);
         reservationRepo.Save();
     }
 }
Esempio n. 22
0
 internal void Remove(int id)
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         chefRepo.Delete(id);
         chefRepo.Save();
     }
 }
Esempio n. 23
0
 internal void Edit(CHEF chef)
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         chefRepo.Update(chef);
         chefRepo.Save();
     }
 }
Esempio n. 24
0
 internal void Add(CHEF chef)
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         chefRepo.Insert(chef);
         chefRepo.Save();
     }
 }
Esempio n. 25
0
 internal void Remove(int id)
 {
     using (entity = new klassycafeEntities())
     {
         reservationRepo = new GenericRepo <RESERVATION>(entity);
         reservationRepo.Delete(id);
         reservationRepo.Save();
     }
 }
Esempio n. 26
0
 public CompanyService(GenericRepo <Kompania> companyRepo, GenericRepo <Prosba> requestRepo, RoleService roleService,
                       GenericRepo <Zolnierz> soldierRepo, UserManager <SystemUser> userManager, IFirebaseService firebaseService)
 {
     _userManager     = userManager;
     _roleService     = roleService;
     _companyRepo     = companyRepo;
     _requestRepo     = requestRepo;
     _soldierRepo     = soldierRepo;
     _firebaseService = firebaseService;
 }
Esempio n. 27
0
 internal void Add(RESERVATION reservation)
 {
     using (entity = new klassycafeEntities())
     {
         reservation.CREATED_DATE = DateTime.Now;
         reservationRepo          = new GenericRepo <RESERVATION>(entity);
         reservationRepo.Insert(reservation);
         reservationRepo.Save();
     }
 }
Esempio n. 28
0
 public FilesService(GenericRepo <Plik> filesRepo, GenericRepo <Zolnierz> soldierRepo, GenericRepo <Katalog> folderRepo,
                     IHostingEnvironment env, UserManager <SystemUser> userManager, GenericRepo <Kompania> companyRepo)
 {
     _env         = env;
     _userManager = userManager;
     _filesRepo   = filesRepo;
     _folderRepo  = folderRepo;
     _soldierRepo = soldierRepo;
     _companyRepo = companyRepo;
 }
Esempio n. 29
0
        public CoffeeOverviewViewModel()
        {
            repository        = new CoffeeRepository();
            coffeeGenericRepo = new GenericRepo <Coffee>();
            Coffees           = new ObservableCollection <Coffee>();

            RefreshCoffees();
            AddCoffeeCommand   = new Command(AddCoffee);
            LoadCoffeesCommand = new Command(RefreshCoffees);
            ItemTapped         = new Command <Coffee>(OnCoffeeSelected);
        }
Esempio n. 30
0
 public PlatoonService(GenericRepo <Pluton> platoonRepo, GenericRepo <Prosba> requestRepo, IFirebaseService firebaseService,
                       GenericRepo <Zolnierz> soldierRepo, UserManager <SystemUser> userManager, ICompanyService companyService, RoleService roleService)
 {
     _userManager     = userManager;
     _roleService     = roleService;
     _platoonRepo     = platoonRepo;
     _requestRepo     = requestRepo;
     _soldierRepo     = soldierRepo;
     _companyService  = companyService;
     _firebaseService = firebaseService;
 }
Esempio n. 31
0
 public GalleriesController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 32
0
 public HomeController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 33
0
 public PagesController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 34
0
 public ImageHelper()
 {
     Repo = new GenericRepo(DBHelper.NHibernateSessionFactory.GetCurrentSession());
 }
Esempio n. 35
0
 public TicketsController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 36
0
 public SettingsController(GenericRepo repo)
 {
     Repo = repo;
     Settings = repo.GetById<Settings>(1) ?? new Settings();
 }
Esempio n. 37
0
 public AccountController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 38
0
 public ArtistsController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 39
0
 public BookingsController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 40
0
 public ImagesController(GenericRepo repo, ImageHelper imageHelper)
 {
     Repo = repo;
     ImageHelper = imageHelper;
 }
Esempio n. 41
0
 public EventsController(GenericRepo repo)
 {
     Repo = repo;
 }
Esempio n. 42
0
 public UsersController(GenericRepo repo)
 {
     Repo = repo;
 }