public IActionResult Delete(int id, EducationArea request) { try { educationAreaDac.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult Create(EducationArea request) { try { educationAreaDac.Insert(request); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void Update(EducationArea data) { using (MySqlConnection conn = context.GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand("UPDATE `sao` SET `sao_type`=@Type,`sao_name`=@Name WHERE `sao_id`=@Id", conn); cmd.Parameters.AddWithValue("@Type", data.sao_type); cmd.Parameters.AddWithValue("@Name", data.sao_name); cmd.Parameters.AddWithValue("@Id", data.sao_id); cmd.ExecuteNonQuery(); } }
public int Insert(EducationArea data) { using (MySqlConnection conn = context.GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand("INSERT INTO `sao`(`sao_id`, `sao_type`, `sao_name`) VALUES (@Id,=@Type,@Name)", conn); cmd.Parameters.AddWithValue("@Type", data.sao_type); cmd.Parameters.AddWithValue("@Name", data.sao_name); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.UtcNow); cmd.ExecuteNonQuery(); return((int)cmd.LastInsertedId); } }
public IActionResult Edit(int id, EducationArea request) { try { var educationArea = educationAreaDac.Get(id); educationArea.sao_name = request.sao_name; educationAreaDac.Update(educationArea); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }