private void taskDeleteBtn_Click(object sender, EventArgs e) { try { Button button = (Button)sender; Panel currentTask = (Panel)button.Parent; string Date = currentTask.Controls.OfType <Label>().ToList().Where(x => x.Name.Contains("taskPanelTitle")).First().Text; string Content = currentTask.Controls.OfType <TextBox>().ToList().Where(x => x.Name.Contains("taskPanelContent")).First().Text; foreach (var item in Loaded_Data_Tasks) { if (item.Alarm_Date == Convert.ToDateTime(Date) && item.Content == Content) { foreach (var value in TaskModel.Date_Table) { if (item.Id == value.Task_ID) { TaskModel.Delete(value); } } } } RefreshForm_Old(); } catch (Exception x) { Console.WriteLine(x.Message); } }
public async Task <IActionResult> Edit(TaskViewModel vModel) { vModel.Task.Id = vModel.Id; vModel.Task.StackId = vModel.StackId; var result = false; if (vModel.Delete) { result = await _taskModel.Delete(vModel.Id); } else { if (!ModelState.IsValid) { vModel.ErrorMessages = ModelState.Where(s => s.Value.Errors.Count > 0) .ToDictionary(s => s.Key, s => s.Value.Errors.Select(e => e.ErrorMessage).ToList()); return(View(vModel)); } vModel.Task.Content = JsonConvert.SerializeObject(vModel.TaskContent); result = await _taskModel.Update(vModel.Task); } if (result) { return(Redirect($"~/task/{vModel.StackId}")); } return(View(vModel)); }
private void deleteBtn_Yes_Click(object sender, EventArgs e) { try { if (SelectedRow_Task != null) { TaskModel.Delete(SelectedRow_Task); RefreshForm_Old(); } } catch (Exception x) { MessageBox.Show("Először válassz ki egy feladatot!"); RefreshForm(); } }