private static void AddModel(Tuple <Type, Type> service) { if (Modelos.ContainsKey(service.Item2)) { throw new DesenvolvimentoIncorretoException($"There are two entity classes with the same Nome {service.Item2.Name}. This is not allowed."); } Modelos.Add(service.Item2, service.Item2); }
public static void AdicionarModelo(Modelo modelo) { foreach (Modelo modeloSalvo in Modelos) { if (modeloSalvo.Codigo == modelo.Codigo && modeloSalvo.Marca.Codigo == modelo.Marca.Codigo) { throw new Exception("O código utilizado nesse modelo já foi cadastrado."); } } Modelos.Add(modelo); SalvarModelos(); }
private void LoadModelos() { Directory.CreateDirectory(BaseDirectoryModelo); foreach (var file in Directory.GetFiles(BaseDirectoryModelo, "*", SearchOption.AllDirectories)) { using (StreamReader streamFile = File.OpenText(file)) { Modelo modeloItem = (Modelo)Serializer.Deserialize(streamFile, typeof(Modelo)); if (modeloItem != null) { Modelos.Add(modeloItem); } } } }
public void SalvarModelo(Modelo modeloSave) { string m_Directory = BaseDirectoryModelo + @"\" + modeloSave.Id; Directory.CreateDirectory(m_Directory); using (StreamWriter sw = new StreamWriter(m_Directory + @"\modelo_" + modeloSave.Id + ".json")) using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.Indented; Serializer.Serialize(writer, modeloSave); } if (Modelos.Any(entry => entry.Id == modeloSave.Id)) { var oldModelo = Modelos.FirstOrDefault(entry => entry.Id == modeloSave.Id); Modelos.Remove(oldModelo); } Modelos.Add(modeloSave); }
public Modelos CargaGeneral(ObtenerModelosRequest datos) { Modelos result = null; try { string[] tipo = datos.idTipo.Split("°"); SybaseEngine SybaseEngine = new SybaseEngine(Configuration.SybaseConnectionString); List <IDataParameter> parameters = new List <IDataParameter> { new AseParameter("@ACCION", AseDbType.Integer) { Value = 4 } , new AseParameter("@MARCA_VEHICULO", AseDbType.Integer) { Value = datos.idMarca } , new AseParameter("@TIP_VEHICULO", AseDbType.Integer) { Value = datos.idTipoVehiculo } , new AseParameter("@TIPO", AseDbType.VarChar) { Value = datos.idTipo } , new AseParameter("@VERSION", AseDbType.VarChar) { Value = datos.idVersion } , new AseParameter("@FECHA", AseDbType.DateTime) { Value = DateTime.Today } , new AseParameter("@TIPOTRANSMISION", AseDbType.VarChar) { Value = datos.idTransmision } }; if (tipo.Length >= 2) { parameters.Add(new AseParameter("@CLAVE_VEHICULO", AseDbType.Integer) { Value = tipo[1] }); if (tipo.Length > 2) { parameters.Add(new AseParameter("@TAR_TARIFAID", AseDbType.Integer) { Value = tipo[2] }); parameters.Add(new AseParameter("@TAR_VERSION", AseDbType.Integer) { Value = tipo[3] }); } } DataSet dset = SybaseEngine.ExecuteDataSet ( SP.Vehiculo.CSTR_USP_AUT_EMI_VEHICULOCARAC, CommandType.StoredProcedure, parameters ); if (dset.Tables != null && dset.Tables.Count > 0) { if (dset.Tables[0].Rows.Count > 0) { result = new Modelos(); foreach (DataRow renglon in dset.Tables[0].Rows) { Modelo modeloAgregar = new Modelo(); modeloAgregar.clave = (renglon.Table.Columns.Contains("VMOD_ANIO") && renglon["VMOD_ANIO"] != DBNull.Value) ? Convert.ToInt32(renglon["VMOD_ANIO"]) : 0; modeloAgregar.descripcion = (renglon.Table.Columns.Contains("VMOD_ANIO") && renglon["VMOD_ANIO"] != DBNull.Value) ? Convert.ToString(renglon["VMOD_ANIO"]) : ""; result.Add(modeloAgregar); } } } } catch (Exception ex) { throw ex; } return(result); }