// GET: Event/Edit/5 public ActionResult Edit(int id) { EventService repo = new EventService(); Event ev = repo.Get(id); EventEditForm events = new EventEditForm(ev); return(View(events)); }
private void button3_Click(object sender, EventArgs e) { //edit if (dataGridView1.CurrentRow != null) { var eef = new EventEditForm(); eef.SetLang(); eef.EventData = changeData.Values[dataGridView1.CurrentRow.Index].Clone(); if (eef.ShowDialog() == DialogResult.OK) { float time = changeData.Keys[dataGridView1.CurrentRow.Index]; changeData.RemoveAt(dataGridView1.CurrentRow.Index); dataGridView1.Rows.RemoveAt(this.dataGridView1.CurrentRow.Index); changeData.Add(time, eef.EventData); this.dataGridView1.Rows.Add(1); UpdateDataGrid(); ContentChanged(); } } }
// GET: Event/Edit/5 public async Task <IActionResult> Edit(string id) { var eventModel = await _context.EventContents .FirstOrDefaultAsync(m => m.Id == id); if (eventModel == null) { return(NotFound()); } var eventForm = new EventEditForm() { Id = eventModel.Id, Title = eventModel.Title, EventDate = eventModel.EventDate, Description = eventModel.Description, Address = eventModel.Address, Phone = eventModel.Phone }; return(View(eventForm)); }
public ActionResult Edit(int id, EventEditForm collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { EventService repo = new EventService(); Event oldData = repo.Get(id); oldData.Name = collection.Name; oldData.Description = collection.Description; oldData.City = collection.City; oldData.Street = collection.Street; oldData.Number = collection.Number; oldData.NumberBox = collection.NumberBox; oldData.ZipCode = collection.ZipCode; oldData.Country = collection.Country; oldData.StartDate = collection.StartDate; oldData.EndDate = collection.EndDate; oldData.FullDay = collection.FullDay; if (repo.Update(oldData)) { RedirectToAction("Index"); } else { return(View(collection)); } } return(RedirectToAction("Index")); } catch { return(View()); } }
private void button1_Click(object sender, EventArgs e) { //add var time = (float)WindowUtility.Seekmain.Currenttime; if (!changeData.ContainsKey(time)) { var eef = new EventEditForm(); eef.SetLang(); if (changeData.Count == 0 || currentnum < 0) { var temp = new EventData { BPM = WindowUtility.IniFileWriter.BPM }; eef.EventData = temp; } else { if (currentnum >= 0 && currentnum < changeData.Count) { eef.EventData = changeData.Values[currentnum].Clone(); } } if (eef.ShowDialog() == DialogResult.OK) { changeData.Add(time, eef.EventData); this.dataGridView1.Rows.Add(1); UpdateDataGrid(); ContentChanged(); } } else { MessageBox.Show(alreadyadded); } }
public async Task <IActionResult> Edit(EventEditForm form) { if (ModelState.IsValid) { var content = await _context.EventContents.FirstOrDefaultAsync(x => x.Id == form.Id); if (content == null) { return(NotFound()); } content.Title = form.Title; content.EventDate = form.EventDate; content.Description = form.Description; content.Address = form.Address; content.Phone = form.Phone; try { _context.Update(content); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(form.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(form)); }