Esempio n. 1
0
 public IActionResult Delete(int id, EducationArea request)
 {
     try
     {
         educationAreaDac.Delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 2
0
 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);
            }
        }
Esempio n. 5
0
        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());
            }
        }