public BaseObject DeleteCourse(int id) { using (CourseLogic logic = new CourseLogic()) { return(logic.DeleteCourse(id)); } }
public async Task <ActionResult> DeleteConfirmed(int id) { try { bool status = await _logic.DeleteCourse(id); return(RedirectToAction("Index")); } catch (SqlException ex) { if (ex.Errors.Count > 0) { if (ex.Errors[0].Number == 547) { ViewBag.Message = "This data can not be deleted,because it is in use."; return(View()); } } ViewBag.Message = "Database error occurred"; return(View()); } catch (Exception) { ViewBag.Message = "Something went wrong while deleting the record."; return(View()); } }
private static void DeleteCourse() { Console.WriteLine("********* Delete course *********"); Console.WriteLine("Course name: "); string courseName = Console.ReadLine(); courseLogic.DeleteCourse(courseName); logs.SendTimestamp("DeleteCourse", "admin", "Delete course: " + courseName); Console.WriteLine("Course deleted correctly"); }
protected void ListControl_Delete(object sender, Course obj) { CourseLogic.DeleteCourse(this.DataContext, obj.ID); this.DataContext.AcceptAllChanges(); BindList(); }