public AdvertisementsView(INavigation nav)
 {
     Navigation = nav;
     InitializeComponent();
     BindingContext = new AdvertisementsViewModel(Navigation);
     list           = new ObservableCollection <Advertisement>()
     {
         new Advertisement()
         {
             Place = "Kraków", RequiredAge = 21, NumberOfPeople = 2, RequiredSex = Sex.FEMALE, Content = "Trip to Hungary! I have no car -> we do AddStop! Hitchhiking is the only kind of trasport I believe in. I love rock music, talking about StarWars and having fun in new places. Willing to go? Sign in and let’s do this!", When = "21.07.2016 - 25.08.2016", src = "https://us.v-cdn.net/5019960/uploads/userpics/167/nNRIE2WKMOXCZ.jpg"
         },
         new Advertisement()
         {
             Place = "Katowice", RequiredAge = 18, NumberOfPeople = 3, RequiredSex = Sex.MALE, Content = "Okay, so this is my first hitchhike trip ever and I want to do this with amazing person. If you feel like you’re the one that’s gonna spend this awesome time together with me just let me know! ", When = "16.05.2016 - 20.05.2016", src = "https://us.v-cdn.net/5019960/uploads/userpics/123/nGMH7CNV8ZTVP.png"
         },
         new Advertisement()
         {
             Place = "Wrocław", RequiredAge = 18, NumberOfPeople = 2, RequiredSex = Sex.FEMALE, Content = "I love travels and photography, but not only. Let’s get to know each other! Waiting for awesome people", When = "30.09.2016 - 05.10.2016", src = "https://us.v-cdn.net/5019960/uploads/userpics/851/nZN50XKL6T074.jpg"
         },
         new Advertisement()
         {
             Place = "Warszawa", RequiredAge = 25, NumberOfPeople = 2, RequiredSex = Sex.FEMALE, Content = "Hey everyone! I’m looking for a mate for an awesome trip to see some of Eastern Europe. I have 2 weeks of spare time and I want to spend it as good as possible - hitchhiking as always! Let’s do it together", When = "21.07.2016 - 25.08.2016", src = "https://i.pinimg.com/736x/28/c0/ef/28c0ef82b165f2b2c12e98106d602a37--girl-face-woman-face.jpg"
         },
         new Advertisement()
         {
             Place = "Londyn", RequiredAge = 30, NumberOfPeople = 2, RequiredSex = Sex.MALE, Content = "Hey everyone! I’m looking for a mate for an awesome trip to see some of Eastern Europe. I have 2 weeks of spare time and I want to spend it as good as possible - hitchhiking as always! Let’s do it together", When = "28.04.2016 - 21.05.2016", src = "https://i.pinimg.com/736x/f3/ab/69/f3ab696a38d266cab6331a38a43fef96--dark-hair-blue-eyes-black-hair-and-freckles.jpg"
         },
         new Advertisement()
         {
             Place = "Berlin", RequiredAge = 18, NumberOfPeople = 2, RequiredSex = Sex.FEMALE, Content = "I love travels and photography, but not only. Let’s get to know each other! Waiting for awesome people", When = "21.07.2016 - 25.07.2016", src = "https://store.halloweenmakeup.com/blog/wp-content/uploads/2014/07/MG_6709-682x1024.jpg"
         },
     };
     listView.ItemsSource = list;
 }
        public bool AddAds(AdvertisementsViewModel model)
        {
            var ads = new AdvertisementDataModel
            {
                Id        = model.Id,
                ImagePath = model.ImagePath,
                Section   = model.Section,
                Order     = model.Order,
                JobPage   = model.JobPage
            };

            return(_advertisementsRepository.AddAds(ads));
        }
        public bool UpdateAds(AdvertisementsViewModel model, int userid)
        {
            var ads = new AdvertisementDataModel
            {
                Id        = model.Id,
                ImagePath = model.ImagePath,
                Section   = model.Section,
                Order     = model.Order,
                JobPage   = model.JobPage
            };

            return(_advertisementsRepository.UpdateAds(ads, userid));
        }
Esempio n. 4
0
        public JsonResult AddDigitalDisplayData([FromForm] AdvertisementsViewModel model)
        {
            var    user  = HttpContext.Session.Get <UserViewModel>(Constants.SessionKeyUserInfo);
            var    resp  = false;
            string fName = "";

            if (model.ImageFile != null)
            {
                //var file = Request.Form.Files[0];
                //var file = Request.Form.Files[0];
                var    file     = model.ImageFile;
                string filename = model.ImageFile.FileName;

                fName    = $@"\Ads\{user.UserId + "_" + filename}";
                filename = _hostingEnviroment.WebRootPath + fName;
                using (FileStream fs = System.IO.File.Create(filename))
                {
                    file.CopyTo(fs);
                }
            }
            try
            {
                model.Id        = user.UserId;
                model.ImagePath = fName;
                resp            = _advertisementsHandler.AddAds(model);
            }
            catch (DataNotFound ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, 0, typeof(DigitalDisplayController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
                resp = false;
            }
            catch (Exception ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, 0, typeof(DigitalDisplayController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
                resp = false;
            }
            return(Json(resp));
        }
Esempio n. 5
0
        public async Task <ActionResult> Index(Filter filter, int page = 1)
        {
            using var client = new ApiClient();
            User user;

            client.Token = Request.Cookies["token"];;
            user         = await client.GetUserAsync();

            int count = 10;

            /*
             * var filter = new Filter
             * {
             * Start = (page - 1) * count,
             * Count = count
             * };
             */
            filter.Count = count;
            filter.Start = (page - 1) * count;
            var responseModel = await client.GetAdvertisementsAsync(filter);

            if (responseModel == null)
            {
                responseModel = new AdvertisementsBindingModel();
            }

            AdvertisementsViewModel model = new AdvertisementsViewModel
            {
                User = user,
                //CurrentPage = page,
                MaxPage        = (responseModel.Count / count) + 1,
                Advertisements = responseModel.Advertisements
            };

            return(View(model));
        }