public static List <LocalizacaoModel> GetListaLocalizacoes(string connectionString) { var listaFinal = new List <LocalizacaoModel>(); var sql = "SELECT * from localizacao"; using (var connection = new SqlConnection(connectionString)) using (var command = new SqlCommand(sql, connection)) { connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var newItem = new LocalizacaoModel { IdLocalizacao = Convert.ToInt16(reader["id_localizacao"]), Localizacao = reader["localizacao"].ToString() }; listaFinal.Add(newItem); } } connection.Close(); } return(listaFinal); }
public ActionResult Delete(int id) { using (LocalizacaoModel model = new LocalizacaoModel()) model.Delete(id); return(RedirectToAction("Index")); }
// GET: Localizacao public ActionResult Index() { using (LocalizacaoModel model = new LocalizacaoModel()) { List <Localizacao> lista = model.Read(); return(View(lista)); } }
public ActionResult Filter(FormCollection form) { // Extamente o name do input search <input name="status"... string status = form["status"]; using (LocalizacaoModel model = new LocalizacaoModel()) { List <Localizacao> lista = model.Read(status); return(View("Index", lista)); } }
public ActionResult Create(FormCollection form) { ComandaEletronica.Entity.Localizacao e = new Localizacao(); e.QtdLugares = int.Parse(form["qtdLugares"]); e.Descricao = form["descricao"]; e.Status = Status.Livre; using (LocalizacaoModel model = new LocalizacaoModel()) { model.Create(e); } return(RedirectToAction("Index")); }
public ActionResult Update(FormCollection form) { Localizacao e = new Localizacao(); e.QtdLugares = int.Parse(form["qtdLugares"]); e.Descricao = form["descricao"]; e.Status = Status.Livre; e.Numero = int.Parse(form["numero"]); using (LocalizacaoModel model = new LocalizacaoModel()) { model.Update(e); } return(RedirectToAction("Index")); }
public ActionResult Update(int numero) { using (LocalizacaoModel model = new LocalizacaoModel()) { return(View(model.Read(numero))); } }