public static List <VrsteHomologacijeModel> GetAllVrsteHomologacijeFromGlavna(int GlavnaMasterID) { List <VrsteHomologacijeModel> list = new List <VrsteHomologacijeModel>(); VrsteHomologacijeModel model = null; SqlConnection connection = Database.GetConnection(); SqlCommand cmd = null; SqlDataReader reader = null; connection.Open(); cmd = new SqlCommand(GET_ALL_VRSTE_HOMOLOGACIJE_FROM_GLAVNA, connection); cmd.Parameters.AddWithValue("@GlavnaMasterID", GlavnaMasterID); cmd.CommandTimeout = 60; reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { model = new VrsteHomologacijeModel(); model.Id = reader.GetInt32(0); model.Naziv = model.Id + " - " + reader.GetString(1); list.Add(model); } reader.Close(); } connection.Close(); return(list); }
public static List <VrsteHomologacijeModel> GetAllVrsteHomologacije(int i) { List <VrsteHomologacijeModel> list = new List <VrsteHomologacijeModel>(); VrsteHomologacijeModel model = null; SqlConnection connection = Database.GetConnection(); SqlCommand cmd = null; SqlDataReader reader = null; connection.Open(); cmd = new SqlCommand(GET_ALL_VRSTE_HOMOLOGACIJE, connection); cmd.CommandTimeout = 60; reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { model = new VrsteHomologacijeModel(); model.Id = reader.GetInt32(0); if (i == 0) { model.Naziv = reader.GetString(1); } else { model.Naziv = model.Id + " - " + reader.GetString(1); } if (!reader.IsDBNull(2)) { model.KomercijalniNaziv = reader.GetString(2); } if (!reader.IsDBNull(3)) { model.UNECE_Pravilnik_dopuna = reader.GetString(3); } if (!reader.IsDBNull(4)) { model.EU_direktiva = reader.GetString(4); } if (!reader.IsDBNull(5)) { model.EU_direktiva_dopuna = reader.GetString(5); } model.Kategorije = reader.GetString(6); model.DatumKreiranjaUTC = reader.GetDateTimeOffset(7).LocalDateTime; if (!reader.IsDBNull(8)) { model.DatumPocetkaPrimjeneUTC = reader.GetDateTimeOffset(8).LocalDateTime; } model.Institucija.AutoID = reader.GetInt32(11); model.Institucija.Naziv = reader.GetString(12); list.Add(model); } reader.Close(); } connection.Close(); return(list); }
public void SaveID([FromBody] VrsteHomologacijeModel vrstaHomologacije) { try { HttpContext.Session.SetInt32("VrstaHomologacijeID", vrstaHomologacije.Id); } catch (Exception) { } }
// GET: TypeHomologIS/Delete/5 public bool Delete([FromBody] VrsteHomologacijeModel vrstaHomologacije) { try { return(VrsteHomologacijeDAO.DeleteHomologisType(vrstaHomologacije.Id)); } catch (Exception) { return(false); } }
public static VrsteHomologacijeModel GetHomologisTypeById(int Id) { VrsteHomologacijeModel model = null; SqlConnection connection = Database.GetConnection(); SqlCommand cmd = null; SqlDataReader reader = null; connection.Open(); cmd = new SqlCommand(GET_HOMOLOGIS_TYPE_BY_ID, connection); cmd.Parameters.AddWithValue("@Id", Id); cmd.CommandTimeout = 60; reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { model = new VrsteHomologacijeModel(); model.Id = reader.GetInt32(0); model.Naziv = reader.GetString(1); if (!reader.IsDBNull(2)) { model.KomercijalniNaziv = reader.GetString(2); } if (!reader.IsDBNull(3)) { model.UNECE_Pravilnik_dopuna = reader.GetString(3); } if (!reader.IsDBNull(4)) { model.EU_direktiva = reader.GetString(4); } if (!reader.IsDBNull(5)) { model.EU_direktiva_dopuna = reader.GetString(5); } model.Kategorije = reader.GetString(6); model.DatumKreiranjaUTC = reader.GetDateTimeOffset(7).LocalDateTime; if (!reader.IsDBNull(8)) { model.DatumPocetkaPrimjeneUTC = reader.GetDateTimeOffset(8).LocalDateTime; } model.Institucija.AutoID = reader.GetInt32(11); model.Institucija.Naziv = reader.GetString(12); } reader.Close(); } connection.Close(); return(model); }
public ActionResult Create(VrsteHomologacijeModel vrsteHomologacijeModel) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } VrsteHomologacijeDAO.CreateNewHomologisType(vrsteHomologacijeModel); return(RedirectToAction(nameof(Index))); } catch (Exception e) { return(View()); } }
public ActionResult SaveEdit(VrsteHomologacijeModel vrstaHomologacije) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } vrstaHomologacije.Id = Convert.ToInt32(HttpContext.Session.GetInt32("VrstaHomologacijeID")); VrsteHomologacijeDAO.UpdateHomologisType(vrstaHomologacije); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public static bool UpdateHomologisType(VrsteHomologacijeModel vrsteHomologacijeModel) { Boolean updated; SqlConnection connection = Database.GetConnection(); SqlCommand cmd = null; connection.Open(); cmd = new SqlCommand(UPDATE_HOMOLOGIS_TYPE, connection); cmd.Parameters.AddWithValue("@Id", vrsteHomologacijeModel.Id); cmd.Parameters.AddWithValue("@Naziv", vrsteHomologacijeModel.Naziv.Trim()); cmd.Parameters.AddWithValue("@KomercijalniNaziv", string.IsNullOrEmpty(vrsteHomologacijeModel.KomercijalniNaziv) ? (object)DBNull.Value : vrsteHomologacijeModel.KomercijalniNaziv.Trim()); cmd.Parameters.AddWithValue("@UNECE_Pravilnik_dopuna", string.IsNullOrEmpty(vrsteHomologacijeModel.UNECE_Pravilnik_dopuna) ? (object)DBNull.Value : vrsteHomologacijeModel.UNECE_Pravilnik_dopuna.Trim()); cmd.Parameters.AddWithValue("@EU_direktiva", string.IsNullOrEmpty(vrsteHomologacijeModel.EU_direktiva) ? (object)DBNull.Value : vrsteHomologacijeModel.EU_direktiva.Trim()); cmd.Parameters.AddWithValue("@EU_direktiva_dopuna", string.IsNullOrEmpty(vrsteHomologacijeModel.EU_direktiva_dopuna) ? (object)DBNull.Value : vrsteHomologacijeModel.EU_direktiva_dopuna.Trim()); cmd.Parameters.AddWithValue("@Kategorije", vrsteHomologacijeModel.Kategorije.Trim()); cmd.Parameters.AddWithValue("@Opis", string.IsNullOrEmpty(vrsteHomologacijeModel.Opis) ? (object)DBNull.Value : vrsteHomologacijeModel.Opis.Trim()); cmd.Parameters.AddWithValue("@ObjekatID", vrsteHomologacijeModel.Institucija.AutoID); cmd.CommandTimeout = 60; updated = cmd.ExecuteNonQuery() > 0 ? true : false; connection.Close(); return(updated); }