コード例 #1
0
        public Lane GetBowlingCenterLane(string id, string bowlingid, string laneid)
        {
            logger.Debug(Settings.MethodName());

            if (isCorrectUser(id))
            {
                S_BowlingCenter bowlingCenter = BowlingCenterManager.GetBowlingCenterById(long.Parse(bowlingid));

                if (bowlingCenter != null && laneid != null)
                {
                    try
                    {
                        int laneID = int.Parse(laneid);

                        if (laneID <= bowlingCenter.numberOfLanes)
                        {
                            Lane lane = new Lane();
                            lane.lanenr = laneID;

                            return(lane);
                        }
                    }
                    catch
                    {
                    }
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: Profile.aspx.cs プロジェクト: tomdevries/NBFQubica
        private void buildCompetitions(S_User user)
        {
            List <S_Competition> competitions = CompetitionManager.GetCompetitionsByPlayer(user.id);


            _competitions  = "<div class='col-lg-8 col-lg-offset-2'>";
            _competitions += "  <h2>Jouw Competities</h2>";
            if (competitions.Count() > 0)
            {
                foreach (S_Competition competition in competitions)
                {
                    S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid);
                    List <S_CompetitonBowlingcenter> competitonBowlingcenters = CompetitionManager.GetBowlingcentersByCompetition(competition.id);

                    _competitions += "  <h3>" + challenge.name + "</h3>";
                    _competitions += " <p> Van " + competition.startdate.ToString("dd-MM-yyyy") + " tot " + competition.enddate.ToString("dd-MM-yyyy") + " bij de volgende bowlingcentra: ";

                    foreach (S_CompetitonBowlingcenter competitonBowlingcenter in competitonBowlingcenters)
                    {
                        S_BowlingCenter bowlingCenter = BowlingCenterManager.GetBowlingCenterById(competitonBowlingcenter.bowlingcenterid);
                        _competitions += "<br/><br/>" + bowlingCenter.name;
                    }

                    _competitions += "</p>";
                }
            }
            else
            {
                _competitions += "  <p>Je doet nog niet mee aan een competitie</p>";
            }
            _competitions += "</div>";
        }
コード例 #3
0
        public ActionResult Edit(long id)
        {
            S_BowlingCenter  bowlingcenter    = BowlingCenterManager.GetBowlingCenterById(id);
            BowlinghuisModel bowlinghuisModel = new BowlinghuisModel();

            bowlinghuisModel.Id            = bowlingcenter.id;
            bowlinghuisModel.Name          = bowlingcenter.name;
            bowlinghuisModel.Address       = bowlingcenter.address;
            bowlinghuisModel.ApiVersion    = bowlingcenter.APIversion;
            bowlinghuisModel.Appname       = bowlingcenter.appname;
            bowlinghuisModel.Secretkey     = bowlingcenter.secretkey;
            bowlinghuisModel.City          = bowlingcenter.city;
            bowlinghuisModel.Email         = bowlingcenter.email;
            bowlinghuisModel.LastSyncDate  = bowlingcenter.lastSyncDate.Value;
            bowlinghuisModel.NumberOfLanes = bowlingcenter.numberOfLanes.Value;
            bowlinghuisModel.Phonenumber   = bowlingcenter.phonenumber;
            bowlinghuisModel.Port          = bowlingcenter.centerId.Value;
            bowlinghuisModel.Uri           = bowlingcenter.uri;
            bowlinghuisModel.UrlLogo       = bowlingcenter.logo;
            bowlinghuisModel.Website       = bowlingcenter.website;
            bowlinghuisModel.ZipCode       = bowlingcenter.zipcode;

            SelectListItem selectListItem = new SelectListItem();

            selectListItem.Value = "1.00.00";
            selectListItem.Text  = "1.00.00";

            bowlinghuisModel.ApiVersions = new Collection <SelectListItem>()
            {
                selectListItem
            };
            return(View(bowlinghuisModel));
        }
コード例 #4
0
        public Lane[] GetBowlingCenterLanes(string id, string bowlingid)
        {
            logger.Debug(Settings.MethodName());

            if (isCorrectUser(id))
            {
                long bowlingCenterID = 0;
                long.TryParse(bowlingid, out bowlingCenterID);

                S_BowlingCenter bowlingCenter = BowlingCenterManager.GetBowlingCenterById(bowlingCenterID);

                if (bowlingCenter != null && bowlingCenter.numberOfLanes != null)
                {
                    Lane[] lanes = new Lane[(int)bowlingCenter.numberOfLanes];

                    for (int laneIndex = 1; laneIndex <= bowlingCenter.numberOfLanes; laneIndex++)
                    {
                        lanes[laneIndex - 1]        = new Lane();
                        lanes[laneIndex - 1].lanenr = laneIndex;
                    }
                    return(lanes);
                }
            }

            return(null);
        }
コード例 #5
0
        public BowlingCenter[] GetBowlingCenters(string id)
        {
            logger.Debug(Settings.MethodName());

            if (isCorrectUser(id))
            {
                List <S_BowlingCenter> bowlingCenterList = BowlingCenterManager.GetBowlingCenters();

                if (bowlingCenterList != null)
                {
                    BowlingCenter[] bowlingCenters = new BowlingCenter[bowlingCenterList.Count()];

                    int i = 0;
                    foreach (S_BowlingCenter bowlingCenter in bowlingCenterList)
                    {
                        bowlingCenters[i] = new BowlingCenter();
                        bowlingCenters[i].bowlingcenterId     = bowlingCenter.id;
                        bowlingCenters[i++].bowlingcenterName = bowlingCenter.name;
                    }

                    return(bowlingCenters);
                }
            }

            return(null);
        }
コード例 #6
0
        public Center GetBowlingCenter(string id, string bowlingid)
        {
            logger.Debug(Settings.MethodName());

            if (isCorrectUser(id))
            {
                S_BowlingCenter bowlingCenter = BowlingCenterManager.GetBowlingCenterById(long.Parse(bowlingid));

                if (bowlingCenter != null)
                {
                    Center center = new Center();

                    center.address           = bowlingCenter.address;
                    center.bowlingcenterId   = long.Parse(bowlingid);
                    center.bowlingcenterName = bowlingCenter.name;
                    center.city        = bowlingCenter.city;
                    center.email       = bowlingCenter.email;
                    center.logo        = bowlingCenter.logo;
                    center.phonenumber = bowlingCenter.phonenumber;

                    List <S_Advert> advertList = AdvertManager.GetAdvertsByBowlingCenterid(center.bowlingcenterId);
                    if (advertList != null)
                    {
                        center.adverts = new AdvertisementInfo[advertList.Count()];
                        int i = 0;

                        foreach (S_Advert advert in advertList)
                        {
                            center.adverts[i] = new AdvertisementInfo();
                            center.adverts[i].advertisement       = advert.advertisement;
                            center.adverts[i].advertisement_www   = advert.advertisement_www;
                            center.adverts[i++].advertisement_url = advert.advertisement_url;
                        }
                    }

                    List <S_Opentime> opentimeList = OpentimeManager.GetOpentimesByBowlingcenterId(center.bowlingcenterId);
                    if (opentimeList != null)
                    {
                        center.times = new Opentime[opentimeList.Count()];
                        int i = 0;
                        foreach (S_Opentime openTime in opentimeList)
                        {
                            center.times[i]          = new Opentime();
                            center.times[i].Day      = openTime.day.ToString();
                            center.times[i].Start    = openTime.openTime;
                            center.times[i++].Finish = openTime.closeTime;
                        }
                    }

                    return(center);
                }
            }

            return(null);
        }
コード例 #7
0
        /// <summary>
        /// for get all CheckboxBowlingcenter
        /// </summary>
        public static IEnumerable <C_Checkbox> GetAll()
        {
            List <C_Checkbox>      cbbcl = new List <C_Checkbox>();
            List <S_BowlingCenter> bcl   = BowlingCenterManager.GetBowlingCenters();

            foreach (S_BowlingCenter bc in bcl)
            {
                cbbcl.Add(new C_Checkbox {
                    Name = bc.name, Id = bc.id
                });
            }

            return(cbbcl);
        }
コード例 #8
0
        public ActionResult Delete(long id)
        {
            try
            {
                BowlingCenterManager.Delete(id);
                TempData["message"] = "Het bowlinghuis is verwijderd.";
            }
            catch (Exception e)
            {
                TempData["error"] = e.Message;
            }

            return(RedirectToAction("index", "Bowlinghuis", new { name = "" }));
        }
コード例 #9
0
        public ActionResult Insert(BowlinghuisModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to save the bowlinghuis
                try
                {
                    S_BowlingCenter bowlingcenter = new S_BowlingCenter();
                    bowlingcenter.name          = model.Name;
                    bowlingcenter.uri           = model.Uri;
                    bowlingcenter.centerId      = model.Port;
                    bowlingcenter.address       = model.Address;
                    bowlingcenter.APIversion    = model.ApiVersion;
                    bowlingcenter.appname       = model.Appname;
                    bowlingcenter.secretkey     = model.Secretkey;
                    bowlingcenter.city          = model.City;
                    bowlingcenter.email         = model.Email;
                    bowlingcenter.lastSyncDate  = model.LastSyncDate;
                    bowlingcenter.logo          = model.UrlLogo;
                    bowlingcenter.numberOfLanes = model.NumberOfLanes;
                    bowlingcenter.phonenumber   = model.Phonenumber;
                    bowlingcenter.website       = model.Website;
                    bowlingcenter.zipcode       = model.ZipCode;

                    BowlingCenterManager.Insert(bowlingcenter);
                    TempData["message"] = "Het bowlinghuis is toegevoegd.";

                    return(RedirectToAction("index", "Bowlinghuis", new { name = "" }));
                }
                catch (Exception e)
                {
                    TempData["error"] = "Er is een fout opgetreden.";
                }
            }

            // If we got this far, something failed, redisplay form
            SelectListItem selectListItem = new SelectListItem();

            selectListItem.Value = "1.00.00";
            selectListItem.Text  = "1.00.00";

            model.ApiVersions = new Collection <SelectListItem>()
            {
                selectListItem
            };

            return(View(model));
        }
コード例 #10
0
        public ActionResult Index(string name)
        {
            ObservableCollection <BowlinghuisGridModel> bowlinghuisList = new ObservableCollection <BowlinghuisGridModel>();

            List <S_BowlingCenter> bowlingcenterList;

            if (String.IsNullOrEmpty(name))
            {
                bowlingcenterList = BowlingCenterManager.GetBowlingCenters();
            }
            else
            {
                bowlingcenterList = BowlingCenterManager.GetBowlingCentersByName(name);

                if (bowlingcenterList.Count() == 0)
                {
                    TempData["error"] = "Er zijn geen bowlinghuizen gevonden.";
                }
                else
                if (bowlingcenterList.Count() == 1)
                {
                    TempData["message"] = "Er is 1 bowlinghuis gevonden.";
                }
                else
                {
                    TempData["message"] = "Er zijn " + bowlingcenterList.Count().ToString() + " bowlinghuizen gevonden.";
                }
            }

            foreach (S_BowlingCenter bowlingcenter in bowlingcenterList)
            {
                BowlinghuisGridModel bhgm = new BowlinghuisGridModel();
                bhgm.id          = bowlingcenter.id;
                bhgm.Name        = bowlingcenter.name;
                bhgm.Address     = bowlingcenter.address;
                bhgm.Zipcode     = bowlingcenter.zipcode;
                bhgm.City        = bowlingcenter.city;
                bhgm.Phonenumber = bowlingcenter.phonenumber;
                bhgm.Appname     = bowlingcenter.appname;
                bhgm.SecretKey   = bowlingcenter.secretkey;

                bowlinghuisList.Add(bhgm);
            }

            return(View(bowlinghuisList));
        }
コード例 #11
0
        public PlayedGames GetPlayedGames(string id, string centerid, string gamedate, string otheruserid)
        {
            logger.Debug(Settings.MethodName());

            PlayedGames playedGames = new PlayedGames();

            if (isCorrectUser(id))
            {
                // voor het opvragen van games van een andere gebruiker, gebruiken we het andere id
                if (!String.IsNullOrEmpty(otheruserid))
                {
                    id = otheruserid;
                }

                long userid;
                long bowlingcenterid;

                int year;
                int month;
                int day;

                try
                {
                    long.TryParse(centerid, out bowlingcenterid);
                    long.TryParse(id, out userid);
                    int.TryParse(gamedate.Substring(0, 4), out year);
                    int.TryParse(gamedate.Substring(4, 2), out month);
                    int.TryParse(gamedate.Substring(6, 2), out day);
                    DateTime gameDate = new DateTime(year, month, day);

                    S_User          user          = UserManager.GetUserById(userid);
                    S_BowlingCenter bowlingcenter = BowlingCenterManager.GetBowlingCenterById(bowlingcenterid);

                    if (user != null && bowlingcenter != null)
                    {
                        playedGames = GameManager.GetPlayedGamesByUserAndBowlingcenterAndDate(user, bowlingcenter, gameDate);
                    }
                }
                catch
                {
                }
            }

            return(playedGames);
        }
コード例 #12
0
        public ActionResult Edit(BowlinghuisModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to save the bowlinghuis
                try
                {
                    S_BowlingCenter bowlingcenter = BowlingCenterManager.GetBowlingCenterById(model.Id);

                    bowlingcenter.name          = model.Name;
                    bowlingcenter.uri           = model.Uri;
                    bowlingcenter.centerId      = model.Port;
                    bowlingcenter.address       = model.Address;
                    bowlingcenter.APIversion    = model.ApiVersion;
                    bowlingcenter.appname       = model.Appname;
                    bowlingcenter.secretkey     = model.Secretkey;
                    bowlingcenter.city          = model.City;
                    bowlingcenter.email         = model.Email;
                    bowlingcenter.lastSyncDate  = model.LastSyncDate;
                    bowlingcenter.logo          = model.UrlLogo;
                    bowlingcenter.numberOfLanes = model.NumberOfLanes;
                    bowlingcenter.phonenumber   = model.Phonenumber;
                    bowlingcenter.website       = model.Website;
                    bowlingcenter.zipcode       = model.ZipCode;

                    BowlingCenterManager.Update(bowlingcenter);
                    TempData["message"] = "Het bowlinghuis " + bowlingcenter.name + " is aangepast.";

                    return(RedirectToAction("index", "Bowlinghuis", new { name = "" }));
                }
                catch (Exception e)
                {
                    TempData["error"] = "Er is een fout opgetreden";
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #13
0
        public ActionResult Edit(long id)
        {
            S_Competition    competition      = CompetitionManager.GetCompetition(id);
            CompetitionModel competitionModel = new CompetitionModel();

            competitionModel.Id          = competition.id;
            competitionModel.challengeId = competition.challengeid;
            competitionModel.challenge   = ChallengeManager.GetChallenge(competition.challengeid).name;
            competitionModel.description = competition.description;
            competitionModel.StartDate   = competition.startdate;
            competitionModel.EndDate     = competition.enddate;
            competitionModel.price       = competition.price;

            List <S_BowlingCenter>           bcl  = BowlingCenterManager.GetBowlingCenters();
            List <S_CompetitonBowlingcenter> cbcl = CompetitionManager.GetBowlingcentersByCompetition(competition.id);

            competitionModel.AllBowlingCentersChecked = bcl.Count == cbcl.Count;

            //var selectedBowlingCenters = CheckboxManager.GetAll()
            //   .Where(x => cbcl.Any(s => x.Id.ToString().Equals(s.bowlingcenterid)))
            //   .ToList();

            List <C_Checkbox> selectedBowlingCenters = new List <C_Checkbox>();

            foreach (S_CompetitonBowlingcenter cbc in cbcl)
            {
                S_BowlingCenter bc = BowlingCenterManager.GetBowlingCenterById(cbc.bowlingcenterid);
                selectedBowlingCenters.Add(new C_Checkbox {
                    Id = cbc.bowlingcenterid, Name = bc.name
                });
            }
            //setup a view model
            competitionModel.AvailableBowlingCenters = CheckboxManager.GetAll().ToList();
            competitionModel.SelectedBowlingCenters  = selectedBowlingCenters;

            return(View(competitionModel));
        }
コード例 #14
0
        /// <summary>
        /// </summary>
        public void Execute()
        {
            logger.Debug("RegisterServerCertificateValidation");
            RegisterServerCertificateValidation();

            // get all the bowling centers we want to poll
            List <S_BowlingCenter> bowlingCenters = BowlingCenterManager.GetBowlingCenters();

            logger.Info("texts count:" + bowlingCenters.Count);

            // foreach bolowing center poll the api and store all the data
            foreach (S_BowlingCenter bowlingCenter in bowlingCenters)
            {
                logger.Info(string.Format("Handling bowlingcenter: {0} {1} using uri : {2}", bowlingCenter.id, bowlingCenter.name, bowlingCenter.uri));
                string APIversion = XMLManager.GetAPIVersion(RestfullClient.GetAPIVersion(bowlingCenter.uri, bowlingCenter.centerId, bowlingCenter.appname, bowlingCenter.secretkey));
                logger.Info(APIversion);

                if (string.Compare(APIversion, bowlingCenter.APIversion) == 0)
                {
                    if (bowlingCenter.numberOfLanes != null)
                    {
                        if (bowlingCenter.numberOfLanes > 0)
                        {
                            DateTime now          = DateTime.Now;
                            DateTime lastSyncDate = DateTime.MinValue;
                            if (bowlingCenter.lastSyncDate != null)
                            {
                                lastSyncDate = bowlingCenter.lastSyncDate.Value;
                            }

                            logger.Info("Start get data from server for bolwing center: " + bowlingCenter.id);

                            // if previous days need to be synchronized, call GetScores, otherwise Call GetLastScores
                            // https://localhost:10011/Scores?lanes=1&fromDate=20141207&toDate=20141207

                            if (lastSyncDate.Year == now.Year && lastSyncDate.Month == now.Month && lastSyncDate.Day == now.Day)
                            {
                                string lanes = string.Concat("1-", bowlingCenter.numberOfLanes.ToString());
                                bowlingCenter.scores = XMLManager.GetScores(RestfullClient.GetLastScores(bowlingCenter.uri, bowlingCenter.centerId, lanes, bowlingCenter.appname, bowlingCenter.secretkey));
                            }
                            else
                            {
                                string lanes = "1";
                                for (int laneNr = 2; laneNr <= bowlingCenter.numberOfLanes; laneNr++)
                                {
                                    lanes = String.Concat(lanes, ",", laneNr.ToString());
                                }

                                bowlingCenter.scores = XMLManager.GetScores(RestfullClient.GetScores(bowlingCenter.uri, bowlingCenter.centerId, lanes, lastSyncDate, now, bowlingCenter.appname, bowlingCenter.secretkey));
                            }
                            logger.Info("Stop get data from server for bolwing center: " + bowlingCenter.id + ", start saving..");

                            bowlingCenter.lastSyncDate = DateTime.Now;

                            BowlingCenterManager.Save(bowlingCenter);
                            logger.Info("Done saveing for bolwing center: " + bowlingCenter.id);
                        }
                        else
                        {
                            logger.Warn(string.Format("Number of lanes is less then 0 for bowlingcneter '{0}'", bowlingCenter.name));
                        }
                    }
                    else
                    {
                        logger.Warn(string.Format("Number of lanes is empty for bowlingcneter '{0}'", bowlingCenter.name));
                    }
                }
                else
                {
                    logger.Warn(string.Format("APIversion '{0}' not supported", APIversion));
                }
            }
        }