public async Task <IActionResult> AddStadium(AddStadiumModel model, IFormCollection StadiumImage) { string storePath = "/images/stadiums/"; var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", "images", "stadiums", StadiumImage.Files[0].FileName); using (var stream = new FileStream(path, FileMode.Create)) { await StadiumImage.Files[0].CopyToAsync(stream); } var stadium = new Stadiums { StadiumName = model.StadiumName, BuiltIn = model.BuiltIn, CountryId = model.CountryId, Capacity = model.Capacity, Address1 = model.Address1, Address2 = model.Address2, PostCode = model.PostCode, ImageUrl1 = storePath + model.ImageS1.FileName, TeamId = model.TeamId }; await _stadiumService.Create(stadium); return(RedirectToAction("Index", "Stadiums")); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title")] Stadiums s) { if (id != s.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(s); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(s.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(s)); }
private void Stadiumbtn_Click(object sender, EventArgs e) { string stname = txtStName.Text; string stnumber = txtStNumber.Text; string[] myArr = new string[] { stname, stnumber }; if (Utilities.isEmpty(myArr)) { Stadiums selectedStadium = db.Stadiums.FirstOrDefault(c => c.Name == stname); if (selectedStadium == null) { Stadiums stadium = new Stadiums(); stadium.Name = stname; stadium.Number = stnumber; db.Stadiums.Add(stadium); db.SaveChanges(); MessageBox.Show("Stadium created successfully!", "success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { lblError.Text = "Stadium name already exist!"; lblError.Visible = true; } } else { lblError.Text = "Please,all the fiel!"; lblError.Visible = true; } }
// Fill selected stadium text to textbox private void cmbStadium_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { Stadiums stadium = cmbStadium.SelectedItem as Stadiums; Stadiums stad = db.Stadiums.Find(stadium.Id); txtName.Text = stad.Name; }
public ActionResult DeleteConfirmed(int id) { Stadiums stadiums = db.Stadiums.Find(id); db.Stadiums.Remove(stadiums); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "StadiumID,StadiumDescription,PeopleAmount,Name")] Stadiums stadiums) { if (ModelState.IsValid) { db.Entry(stadiums).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stadiums)); }
public async Task <IActionResult> Create([Bind("ID,Title")] Stadiums s) { if (ModelState.IsValid) { _context.Add(s); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(s)); }
public ActionResult Create([Bind(Include = "StadiumID,StadiumDescription,PeopleAmount,Name")] Stadiums stadiums) { if (ModelState.IsValid) { db.Stadiums.Add(stadiums); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stadiums)); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { Stadiums con = db.Stadiums.FirstOrDefault(x => x.Id == Meydanca.Id); db.Stadiums.Remove(con); db.SaveChanges(); MessageBox.Show("Şəxs silindi"); Sta.fillStadiums(); Fillstadiums(); this.Close(); }
// GET: Stadiums/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Stadiums stadiums = db.Stadiums.Find(id); if (stadiums == null) { return(HttpNotFound()); } return(View(stadiums)); }
//Fill stadiums to stadium combobox from database public void fillStadiums() { cmbStadiums.Items.Clear(); Stadiums stad = db.Stadiums.FirstOrDefault(s => s.Name == cmbStadiums.Text); DateTime date = dtpPlayTime.SelectedDate.Value; if (cmbHours.SelectedItem != null) { string hour = cmbHours.SelectedItem.ToString(); TimeSpan time = TimeSpan.Parse(hour); foreach (Stadiums std in db.Stadiums.Where(s => s.Bookings.Where(b => b.Date == date && b.Time == time).Count() == 0).ToList()) { cmbStadiums.Items.Add(std.Name); } } }
//Fill rezerved stadiums to search combobox public void fillSearchStadiums() { cmbStadiums.Items.Clear(); Stadiums all = new Stadiums { Id = 0, Name = "Hamısı" }; cmbSearchStadium.Items.Add(all); cmbSearchStadium.SelectedValuePath = "0"; foreach (Stadiums std in db.Stadiums.ToList()) { cmbSearchStadium.Items.Add(std); } }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Coaches.AddRange(await this.leagueService.GetCoachList()); this.Stadiums.AddRange(await this.leagueService.GetStadiumsList()); int?teamId = (int?)navigationContext.Parameters["id"]; if (!teamId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddTeam(this.Team); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Team.CoachId = this.SelectedCoach.Id; this.Team.StadiumId = this.SelectedStadium.Id; await this.leagueService.SaveChangesAsync(); //regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); GlobalCommands.GoBackCommand.Execute(null); }); this.Team = await this.leagueService.GetTeam(teamId.Value); this.SelectedCoach = Coaches.FirstOrDefault(c => c.Id == Team.CoachId); this.SelectedStadium = Stadiums.FirstOrDefault(s => s.Id == Team.StadiumId); if (this.Team.Footballers != null) { this.Footballers.AddRange(Team.Footballers); } if (this.Team.Table != null) { this.Tables.AddRange(Team.Table); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
private void CmbStadiums_SelectionChanged(object sender, SelectionChangedEventArgs e) { Stadiums name = CmbStadiums.SelectedItem as Stadiums; if (name != null) { MessageBox.Show(name.ToString()); Stadiums stadium = db.Stadiums.Find(name.Id); if (stadium != null) { TxtStadium.Text = stadium.Name; } } Stadiums stad = db.Stadiums.FirstOrDefault(s => s.Name == CmbStadiums.Text); if (stad != null) { stad.Name = TxtStadium.Text; } }
//Stadionlari elave etmek ucun metod. #region FillStadium public void fillStadiums() { CmbStadiums.Items.Clear(); Stadiums stad = db.Stadiums.FirstOrDefault(s => s.Name == CmbStadiums.Text); DateTime date = ClnCalendar.SelectedDate.Value; if (CmbHours.SelectedItem != null) { string hour = CmbHours.SelectedItem.ToString(); TimeSpan time = TimeSpan.Parse(hour); foreach (Stadiums stadium in db.Stadiums.Where(s => s.Bookings.Where(b => b.Date == date && b.Time == time).Count() == 0).ToList().OrderBy(n => n.Name)) { CmbStadiums.Items.Add(stadium); } } }
private void fillcmbSearcStadium() { cmbSearchStadiums.Items.Clear(); CmbStadiums.Items.Clear(); Stadiums stadiumAll = new Stadiums { Id = 0, Name = "-Hamısı-" }; cmbSearchStadiums.Items.Add(stadiumAll); cmbSearchStadiums.SelectedValuePath = "0"; foreach (Stadiums stadium in db.Stadiums.ToList().OrderBy(n => n.Name)) { cmbSearchStadiums.Items.Add(stadium); } }
// Stadion yenilemek private void BtnUpdate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(TxtStadium.Text)) { MessageBox.Show("xanalari doldur"); return; } Stadiums C = db.Stadiums.Find(Meydanca.Id); C.Name = TxtStadium.Text; db.SaveChanges(); MessageBox.Show("Meydanca yeniləndi"); Fillstadiums(); Sta.fillStadiums(); this.Close(); }
private void BtnUpdate_Delete_Stad_Click(object sender, RoutedEventArgs e) { if (CmbStadiums.SelectedItem == null) { MessageBox.Show("sehv var"); LblStadium.Foreground = Brushes.Red; return; } Stadiums vwReservs = CmbStadiums.SelectedItem as Stadiums; Stadium updateStadium = new Stadium(this); updateStadium.ShowDialog(); LblStadium.Foreground = Brushes.White; updateStadium.Title = "Yenilə və ya Sil"; updateStadium.LblEntry.Content = "Meydanca yenilə və ya sil"; updateStadium.ForUpdate(); updateStadium.Meydanca = db.Stadiums.Find(vwReservs.Id); updateStadium.FillAllFields(); }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(TxtStadium.Text)) { MessageBox.Show("Zəhmət olmasa Meydança əlavə edin"); return; } CmbStadiums.Items.Clear(); Stadiums stadium = new Stadiums { Id = Convert.ToInt32(CmbStadiums.SelectedValue), Name = TxtStadium.Text }; db.Stadiums.Add(stadium); db.SaveChanges(); Sta.fillStadiums(); Close(); }
//Add stadium data to database when click addButton private void btnAddStadium_Click(object sender, RoutedEventArgs e) { if (db.Stadiums.FirstOrDefault(s => s.Name == txtName.Text) != null) { MessageBox.Show("Artıq bu adda stadion əlavə olunub!"); return; } txtName.Text = ""; cmbStadium.Items.Clear(); Stadiums stadium = new Stadiums { Name = txtName.Text }; db.Stadiums.Add(stadium); db.SaveChanges(); MessageBox.Show("Stadion əlavə edildi!"); this.stadium.fillStadiums(); txtName.Text = ""; fillStadiums(); }
public async Task Create(Stadiums stadiums) { _db.Add(stadiums); await _db.SaveChangesAsync(); }
private void cmbStadium_SelectedIndexChanged(object sender, EventArgs e) { string stname = cmbStadium.Text; selectedStadium = db.Stadiums.FirstOrDefault(s => s.Name == stname); }