public ActionResult DeleteHomestay(string id) { if (id == null) { return(RedirectToAction("List", "BackendHomestay", new { area = "Backend" })); } else { int a; bool check = int.TryParse(id.ToString(), out a); if (check == true) { var result = context.homestays.Find(a); if (result == null) { return(RedirectToAction("List", "BackendHomestay", new { area = "Backend" })); } else { client.DeleteHomestay_BE(int.Parse(id)); //context.homestays.Remove(result); //context.SaveChanges(); return(RedirectToAction("List", "BackendHomestay", new { area = "Backend" })); } } else { return(RedirectToAction("List", "BackendHomestay", new { area = "Backend" })); } } }
private void btnXoa_Click(object sender, EventArgs e) { if (id == -1) { MessageBox.Show("Chưa chọn hotel để xoá "); } else { client.DeleteHomestay_BE(id); FormHomestay_Load(sender, e); MessageBox.Show("Xoá thành công"); } }