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); }
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>"; }
private static S_BowlingCenter DataToObject(MySqlDataReader dataReader) { S_BowlingCenter bowlingCenter = new S_BowlingCenter(); bowlingCenter.id = Conversion.SqlToIntOrNull(dataReader["id"]).Value; bowlingCenter.name = Conversion.SqlToString(dataReader["name"]); bowlingCenter.uri = Conversion.SqlToString(dataReader["uri"]); bowlingCenter.centerId = Conversion.SqlToIntOrNull(dataReader["centerId"]).Value; bowlingCenter.APIversion = Conversion.SqlToString(dataReader["apiversion"]); bowlingCenter.numberOfLanes = Conversion.SqlToIntOrNull(dataReader["numberoflanes"]).Value; bowlingCenter.lastSyncDate = Conversion.SqlToDateTimeOrNull(dataReader["lastsyncdate"]); bowlingCenter.appname = Conversion.SqlToString(dataReader["appname"]); bowlingCenter.secretkey = Conversion.SqlToString(dataReader["secretkey"]); bowlingCenter.address = Conversion.SqlToString(dataReader["address"]); bowlingCenter.city = Conversion.SqlToString(dataReader["city"]); bowlingCenter.email = Conversion.SqlToString(dataReader["email"]); bowlingCenter.logo = Conversion.SqlToString(dataReader["logo"]); bowlingCenter.phonenumber = Conversion.SqlToString(dataReader["phonenumber"]); bowlingCenter.website = Conversion.SqlToString(dataReader["website"]); bowlingCenter.zipcode = Conversion.SqlToString(dataReader["zipcode"]); return(bowlingCenter); }
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); }
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)); }
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); }
//Insert statement public static long?Insert(S_BowlingCenter bowlingCenter) { long?lastInsertedId = null; try { DatabaseConnection databaseconnection = new DatabaseConnection(); //open connection if (databaseconnection.OpenConnection()) { //create command and assign the query and connection from the constructor MySqlCommand command = new MySqlCommand(); command.Connection = databaseconnection.getConnection(); command.CommandText = "INSERT INTO bowlingcenter ( email, uri, centerId, apiversion, numberoflanes, lastsyncdate, address, city, email, logo, phonenumber, website, zipcode, appname, secretkey) " + "VALUES (@email, @uri, @centerId, @apiversion, @numberoflanes, @lastsyncdate, @address, @city, @email, @logo, @phonenumber, @website, @zipcode, @appname, @secretkey)"; command.Parameters.AddWithValue("@email", Conversion.StringToSql(bowlingCenter.name)); command.Parameters.AddWithValue("@uri", Conversion.StringToSql(bowlingCenter.uri)); command.Parameters.AddWithValue("@centerId", Conversion.IntToSql(bowlingCenter.centerId)); command.Parameters.AddWithValue("@apiversion", Conversion.StringToSql(bowlingCenter.APIversion)); command.Parameters.AddWithValue("@numberoflanes", Conversion.IntToSql(bowlingCenter.numberOfLanes)); command.Parameters.AddWithValue("@lastsyncdate", Conversion.DateTimeToSql(bowlingCenter.lastSyncDate)); command.Parameters.AddWithValue("@address", Conversion.StringToSql(bowlingCenter.address)); command.Parameters.AddWithValue("@city", Conversion.StringToSql(bowlingCenter.city)); command.Parameters.AddWithValue("@email", Conversion.StringToSql(bowlingCenter.email)); command.Parameters.AddWithValue("@logo", Conversion.StringToSql(bowlingCenter.logo)); command.Parameters.AddWithValue("@phonenumber", Conversion.StringToSql(bowlingCenter.phonenumber)); command.Parameters.AddWithValue("@website", Conversion.StringToSql(bowlingCenter.website)); command.Parameters.AddWithValue("@zipcode", Conversion.StringToSql(bowlingCenter.zipcode)); command.Parameters.AddWithValue("@appname", Conversion.StringToSql(bowlingCenter.appname)); command.Parameters.AddWithValue("@secretkey", Conversion.StringToSql(bowlingCenter.secretkey)); //Execute command command.ExecuteNonQuery(); lastInsertedId = command.LastInsertedId; //close connection databaseconnection.CloseConnection(); } } catch (Exception ex) { logger.Error(string.Format("Insert, Error inserting bowlingcenter data: {0}", ex.Message)); } return(lastInsertedId.Value); }
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)); }
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); }
//Update statement public static void Update(S_BowlingCenter bowlingCenter) { try { DatabaseConnection databaseconnection = new DatabaseConnection(); //open connection if (databaseconnection.OpenConnection()) { //create command and assign the query and connection from the constructor MySqlCommand command = new MySqlCommand(); command.Connection = databaseconnection.getConnection(); command.CommandText = "UPDATE bowlingcenter SET email=@email, uri=@uri, centerId=@centerId, apiversion=@apiversion, numberoflanes=@numberoflanes, lastsyncdate=@lastsyncdate, address=@address, city=@city, email=@email , logo=@logo, phonenumber=@phonenumber, website=@website, zipcode=@zipcode, appname=@appname, secretkey=@secretkey WHERE id=@id "; command.Parameters.AddWithValue("@id", Conversion.LongToSql(bowlingCenter.id)); command.Parameters.AddWithValue("@email", Conversion.StringToSql(bowlingCenter.name)); command.Parameters.AddWithValue("@uri", Conversion.StringToSql(bowlingCenter.uri)); command.Parameters.AddWithValue("@centerId", Conversion.IntToSql(bowlingCenter.centerId)); command.Parameters.AddWithValue("@apiversion", Conversion.StringToSql(bowlingCenter.APIversion)); command.Parameters.AddWithValue("@numberoflanes", Conversion.IntToSql(bowlingCenter.numberOfLanes)); command.Parameters.AddWithValue("@lastsyncdate", Conversion.DateTimeToSql(bowlingCenter.lastSyncDate)); command.Parameters.AddWithValue("@address", Conversion.StringToSql(bowlingCenter.address)); command.Parameters.AddWithValue("@city", Conversion.StringToSql(bowlingCenter.city)); command.Parameters.AddWithValue("@email", Conversion.StringToSql(bowlingCenter.email)); command.Parameters.AddWithValue("@logo", Conversion.StringToSql(bowlingCenter.logo)); command.Parameters.AddWithValue("@phonenumber", Conversion.StringToSql(bowlingCenter.phonenumber)); command.Parameters.AddWithValue("@website", Conversion.StringToSql(bowlingCenter.website)); command.Parameters.AddWithValue("@zipcode", Conversion.StringToSql(bowlingCenter.zipcode)); command.Parameters.AddWithValue("@appname", Conversion.StringToSql(bowlingCenter.appname)); command.Parameters.AddWithValue("@secretkey", Conversion.StringToSql(bowlingCenter.secretkey)); //Execute command command.ExecuteNonQuery(); //close connection databaseconnection.CloseConnection(); } } catch (Exception ex) { logger.Error(string.Format("Update, Error updating bowlingcenter data: {0}", ex.Message)); } }
public static void Save(S_BowlingCenter bowlingCenter) { logger.Info("Start saving"); if (bowlingCenter != null) { try { if (BowlingCenterExistById(bowlingCenter.id)) { DatabaseConnection databaseconnection = new DatabaseConnection(); //open connection if (databaseconnection.OpenConnection()) { MySqlConnection sqlConnection = databaseconnection.getConnection(); // save the scores if (bowlingCenter.scores != null) { ScoresManager.Save(sqlConnection, bowlingCenter.id, bowlingCenter.scores); } else { logger.Warn("Er zijn geen scores"); } //close connection databaseconnection.CloseConnection(); } // update the last_syncdate set by the servicehandler Update(bowlingCenter); } } catch (Exception ex) { logger.Error("fout bij het opslaan van de scores: " + ex.Message); } } logger.Info("End saving"); }
public static S_BowlingCenter GetBowlingCenterById(long id) { S_BowlingCenter bowlingCenter = null; try { DatabaseConnection databaseconnection = new DatabaseConnection(); //Open connection if (databaseconnection.OpenConnection()) { //Create Command MySqlCommand command = new MySqlCommand(); command.Connection = databaseconnection.getConnection(); command.CommandText = "SELECT * FROM bowlingcenter WHERE id=@id"; command.Parameters.AddWithValue("@id", Conversion.LongToSql(id)); //Create a data reader and Execute the command MySqlDataReader dataReader = command.ExecuteReader(); //Read the data and store them in the list if (dataReader.Read()) { bowlingCenter = DataToObject(dataReader); } //close Data Reader dataReader.Close(); //close Connection databaseconnection.CloseConnection(); } } catch (Exception ex) { logger.Error(string.Format("GetBowlingCenterById, Error reading bowlingcenter data: {0}", ex.Message)); } return(bowlingCenter); }
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)); }
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)); }