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(); }
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); }
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]); } } }
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); } }
public RegisterService(UserManager <SystemUser> userManager, GenericRepo <Zolnierz> zolnierzRepo, UserService userService) { _userManager = userManager; _zolnierzRepo = zolnierzRepo; _userService = userService; }
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()); } }
internal MENUITEM GetById(int id) { using (entity = new klassycafeEntities()) { menuItemRepo = new GenericRepo <MENUITEM>(entity); return(menuItemRepo.FindByID(id)); } }
internal List <MENUITEM> GetActives() { using (entity = new klassycafeEntities()) { menuItemRepo = new GenericRepo <MENUITEM>(entity); return(menuItemRepo.Select(mc => mc.STATE_ID == 1).ToList()); } }
internal List <STATE> GetAll() { using (entity = new klassycafeEntities()) { stateRepo = new GenericRepo <STATE>(entity); return(stateRepo.Select().ToList()); } }
internal List <CHEF> GetActives() { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); return(chefRepo.Select(c => c.STATE_ID == 1).ToList()); } }
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()); } }
internal CHEF GetById(int id) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); return(chefRepo.FindByID(id)); } }
internal List <CHEF> GetAll() { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); return(chefRepo.Select().ToList()); } }
internal USER GetByEmail(string email) { using (entity = new klassycafeEntities()) { userRepo = new GenericRepo <USER>(entity); return(userRepo.FindByLambda(u => u.EMAIL == email)); } }
internal void Remove(int id) { using (entity = new klassycafeEntities()) { menuItemRepo = new GenericRepo <MENUITEM>(entity); menuItemRepo.Delete(id); menuItemRepo.Save(); } }
internal void Update(CONTACT CONTACT) { using (entity = new klassycafeEntities()) { ContactRepo = new GenericRepo <CONTACT>(entity); ContactRepo.Update(CONTACT); ContactRepo.Save(); } }
internal void Add(MENUITEM menuitem) { using (entity = new klassycafeEntities()) { menuItemRepo = new GenericRepo <MENUITEM>(entity); menuItemRepo.Insert(menuitem); menuItemRepo.Save(); } }
internal void Edit(MENUITEM menuitem) { using (entity = new klassycafeEntities()) { menuItemRepo = new GenericRepo <MENUITEM>(entity); menuItemRepo.Update(menuitem); menuItemRepo.Save(); } }
internal void Edit(RESERVATION reservation) { using (entity = new klassycafeEntities()) { reservationRepo = new GenericRepo <RESERVATION>(entity); reservationRepo.Update(reservation); reservationRepo.Save(); } }
internal void Remove(int id) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); chefRepo.Delete(id); chefRepo.Save(); } }
internal void Edit(CHEF chef) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); chefRepo.Update(chef); chefRepo.Save(); } }
internal void Add(CHEF chef) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); chefRepo.Insert(chef); chefRepo.Save(); } }
internal void Remove(int id) { using (entity = new klassycafeEntities()) { reservationRepo = new GenericRepo <RESERVATION>(entity); reservationRepo.Delete(id); reservationRepo.Save(); } }
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; }
internal void Add(RESERVATION reservation) { using (entity = new klassycafeEntities()) { reservation.CREATED_DATE = DateTime.Now; reservationRepo = new GenericRepo <RESERVATION>(entity); reservationRepo.Insert(reservation); reservationRepo.Save(); } }
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; }
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); }
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; }
public GalleriesController(GenericRepo repo) { Repo = repo; }
public HomeController(GenericRepo repo) { Repo = repo; }
public PagesController(GenericRepo repo) { Repo = repo; }
public ImageHelper() { Repo = new GenericRepo(DBHelper.NHibernateSessionFactory.GetCurrentSession()); }
public TicketsController(GenericRepo repo) { Repo = repo; }
public SettingsController(GenericRepo repo) { Repo = repo; Settings = repo.GetById<Settings>(1) ?? new Settings(); }
public AccountController(GenericRepo repo) { Repo = repo; }
public ArtistsController(GenericRepo repo) { Repo = repo; }
public BookingsController(GenericRepo repo) { Repo = repo; }
public ImagesController(GenericRepo repo, ImageHelper imageHelper) { Repo = repo; ImageHelper = imageHelper; }
public EventsController(GenericRepo repo) { Repo = repo; }
public UsersController(GenericRepo repo) { Repo = repo; }