Ejemplo n.º 1
0
        public ActionResult Test()
        {
            LogInOperation operation = new LogInOperation();

            using (var db = new SystemContext())
            {
                Random       rnd         = new Random();
                List <Event> RandomEvent = new List <Event>();
                if ((User.Identity.IsAuthenticated) && (Session["Email"] != null))
                {
                    for (int i = 0; i < 3; i++)
                    {
                        int numId = rnd.Next(1, db.Events.Count());
                        RandomEvent.Add(db.Events.Where(n => n.Id == numId).First());
                    }
                    operation.TasteCalculation(RandomEvent, (string)(Session["Email"]));
                    ViewBag.RandomTest = Mapper.Map <List <Event>, List <EventViewModel> >(RandomEvent);
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        int numId = rnd.Next(1, db.Events.Count());
                        RandomEvent.Add(db.Events.Where(n => n.Id == numId).First());
                    }
                    ViewBag.RandomTest = Mapper.Map <List <Event>, List <EventViewModel> >(RandomEvent);
                }
            }
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Like(int id)
        {
            LogInOperation operation = new LogInOperation();

            if ((id != null) && (!string.IsNullOrEmpty((string)(Session["Email"]))))
            {
                operation.LikeOperation(id, (string)(Session["Email"]));
            }
            return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            //await SaveEventToDB();
            if ((User.Identity.IsAuthenticated) && (Session["Email"] != null))
            {
                using (var db = new SystemContext())
                {
                    string           UserEmail          = (string)(Session["Email"]);
                    User             SelUser            = db.Users.Single(n => n.Email == UserEmail);
                    List <TCategory> UserCategoryRating = SelUser.Favourite.FavCategory;

                    Dictionary <string, int> SelectedCategory = new Dictionary <string, int>();
                    //List<string> SelectedCategory = new List<string>();
                    //List<int> SelectedCategoryPrecent = new List<int>();
                    Category AllCateogory = new Category();

                    foreach (var item in AllCateogory.Categorys)
                    {
                        SelectedCategory.Add(item.Key, (int)UserCategoryRating.Where(n => n.title == item.Key).Select(n => n.precents).First());
                    }
                    Random       rnd           = new Random();
                    List <Event> SelectedEvent = new List <Event>();
                    int          countPrecent  = 0;

                    foreach (var item in SelectedCategory)
                    {
                        int numId = 0;
                        for (int i = 0; i < item.Value; i++)
                        {
                            int start = db.Events.Where(n => n.Category == item.Key).Select(n => n.Id).First();
                            int end   = start + db.Events.Where(n => n.Category == item.Key).Count() - 1;
                            numId = rnd.Next(start, end);
                            List <Event> e = db.Events.Where(n => n.Category == item.Key.ToString()).ToList();
                            SelectedEvent.Add(e.Where(n => n.Id == numId).FirstOrDefault());
                        }
                    }
                    ViewBag.WszystkieKategorie = Mapper.Map <List <Event>, List <EventViewModel> >(SelectedEvent);
                }
            }
            using (var db = new SystemContext())
            {
                if ((User.Identity.IsAuthenticated) && (Session["Email"] != null))
                {
                    LogInOperation operation = new LogInOperation();
                    List <Event>   events    = db.Events.Where(n => n.Category == "Muzyka").ToList();
                    operation.TasteCalculation(events, (string)(Session["Email"]));
                    ViewBag.Muzyka = Mapper.Map <List <Event>, List <EventViewModel> >(events);
                }
            }
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult Offerts()
        {
            LogInOperation operation = new LogInOperation();

            using (var db = new SystemContext())
            {
                List <Event> events;
                if ((User.Identity.IsAuthenticated) && (Session["Email"] != null))
                {
                    events = db.Events.ToList();
                    operation.TasteCalculation(events, (string)(Session["Email"]));
                    ViewBag.test2 = Mapper.Map <List <Event>, List <EventViewModel> >(events);
                }
                else
                {
                    events        = db.Events.ToList();
                    ViewBag.test2 = Mapper.Map <List <Event>, List <EventViewModel> >(events);
                }
            }
            return(View());
        }