Example #1
0
 public void Add(BrowseService service)
 {
     lock (mutex) {
         Services.Add(service.Usn, service);
         client.CacheServiceAdded(service);
         service.TimeoutId = timeouts.Add(service.Expiration, TimeoutHandler, service);
     }
 }
Example #2
0
        //---------Login-------------------------
        public IActionResult Index([FromServices] BrowseService bs, [FromServices] CartService cs, string query = "")
        {
            List <Product> products = bs.GetProducts(query);

            ViewData["products"] = products;
            ViewData["username"] = HttpContext.Session.GetString("username");
            int customerId = HttpContext.Session.GetInt32("customerId") ?? 0;

            ViewData["ItemCount"] = cs.GetNumberOfCartItem(customerId);
            return(View());
        }
Example #3
0
        public IActionResult BrowseNoLogin([FromServices] BrowseService bs, [FromServices] CartService srv, string query = "")
        {
            List <Product> products   = bs.GetProducts(query);
            int            customerId = HttpContext.Session.GetInt32("customerId") ?? 0;

            ViewBag.keyword       = query;
            ViewData["ItemCount"] = srv.GetNumberOfCartItem(customerId);
            ViewData["products"]  = products;

            return(View("Index"));
        }
Example #4
0
        public IActionResult BrowseAftLogin([FromServices] BrowseService bs, [FromServices] CartService srv, string query1 = "")
        {
            List <Product> products = bs.GetProducts(query1);

            ViewData["products"] = products;
            ViewData["username"] = HttpContext.Session.GetString("username");
            int customerId = HttpContext.Session.GetInt32("customerId") ?? 0;

            ViewBag.keyword       = query1;
            ViewData["ItemCount"] = srv.GetNumberOfCartItem(customerId);
            return(View("AfterLogin"));
        }
        public BrowseServiceTests()
        {
            AutoMapperConfig.RegisterMappings(Assembly.Load("HiWorld.Services.Data.Tests"));

            var connection = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString());

            this.dbContext = new ApplicationDbContext(connection.Options);
            this.dbContext.Database.EnsureCreated();

            this.pageRepository             = new EfDeletableEntityRepository <Page>(this.dbContext);
            this.postsRepository            = new EfDeletableEntityRepository <Post>(this.dbContext);
            this.profilesRepository         = new EfDeletableEntityRepository <Profile>(this.dbContext);
            this.profileFollowersRepository = new EfRepository <ProfileFollower>(this.dbContext);
            this.pageFollowersRepository    = new EfRepository <PageFollower>(this.dbContext);
            this.browseService = new BrowseService(
                this.pageRepository,
                this.postsRepository,
                this.profilesRepository,
                this.profileFollowersRepository,
                this.pageFollowersRepository);
        }
        public DirInfo Get(string dir = null)
        {
            BrowseService service = new BrowseService();

            return(service.GetDirectoryInfo(dir));
        }
Example #7
0
        public IActionResult AfterLogin([FromServices] LoginService ls, string username, string password, [FromServices] BrowseService bs, [FromServices] CartService cs, string query1 = "")
        {
            int val = ls.Login(username, password, HttpContext.Session);

            if (val == 1)
            {
                TempData["err"] = "Username does not exist";
                return(RedirectToAction("Login", "Home"));
            }
            else if (val == 2)
            {
                TempData["err"] = "Incorrect password";
                return(RedirectToAction("Login", "Home"));
            }
            else if (val == 3)
            {
                ViewData["username"] = username;
                HttpContext.Session.SetString("username", username);

                ViewData["username"] = HttpContext.Session.GetString("username");
            }
            if (ViewData["username"] != null)
            {
                List <Product> products = bs.GetProducts(query1);
                ViewData["products"] = products;
                var customerId  = HttpContext.Session.GetInt32("customerId") ?? 0;
                var sessionCart = HttpContext.Session.GetString("Cart");
                if (sessionCart != null)
                {
                    var cart = JsonConvert.DeserializeObject <Cart>(sessionCart);
                    cs.AddCartWithCustomer(customerId, cart);
                    ViewData["ItemCount"] = cart.Quantity;
                }
                else
                {
                    ViewData["ItemCount"] = cs.GetNumberOfCartItem(customerId);
                }
            }
            return(View());
        }
Example #8
0
 public void Add (BrowseService service)
 {
     lock (mutex) {
         Services.Add (service.Usn, service);
         client.CacheServiceAdded (service);
         service.TimeoutId = timeouts.Add (service.Expiration, TimeoutHandler, service);
     }
 }
Example #9
0
 public HomeController()
 {
     browseRequestConverter = new BrowseRequestConverter();
     browseService          = new BrowseService();
 }
 public TestService(BrowseService browseService)
 {
     _browseService = browseService;
 }
Example #11
0
        private void OnItemRemove(int @interface, Protocol protocol, string name, string type, 
            string domain, LookupResultFlags flags)
        {
            lock (this) {
                BrowseService service = new BrowseService (name, type, domain, @interface, protocol);

                if (services.ContainsKey (name)) {
                    services[name].Dispose ();
                    services.Remove (name);
                }

                OnServiceRemoved (service);
                service.Dispose ();
            }
        }
Example #12
0
 protected virtual void OnServiceRemoved(BrowseService service)
 {
     ServiceBrowseEventHandler handler = ServiceRemoved;
     if (handler != null) {
         handler (this, new ServiceBrowseEventArgs (service));
     }
 }