using System; using System.Runtime.CompilerServices; namespace Gestor.Model.CalculoWeb.Auto { public class Veiculo { private string _combustivel; public string Alienado { get; set; } public string AnoFabricacao { get; set; } public string AnoModelo { get; set; } public string Antifurto { get; set; } public string Blindado { get; set; } public string CepPernoite { get; set; } public string CodigoFipe { get; set; } public string Combustivel { get { return this._combustivel; } set { this._combustivel = value; Veiculo.ConvertCombustivelCalculo(this._combustivel); } } public string Fabricante { get; set; } public Gestor.Model.CalculoWeb.Auto.Fipe Fipe { get; set; } public long Id { get; set; } public string KitGas { get; set; } public string Modelo { get; set; } public string NumeroChassi { get; set; } public string Placa { get; set; } public string Rastreador { get; set; } public string Uf { get; set; } public string ZeroKm { get; set; } public Veiculo() { } private static string ConvertCombustivelCalculo(string combustivel) { if (combustivel != null) { int length = combustivel.Length; if (length == 1) { switch (combustivel[0]) { case '1': { return "3"; } case '2': { return "2"; } case '3': { return "4"; } case '4': { return "1"; } case '5': case '7': case '8': { return "6"; } case '6': { return string.Empty; } case '9': { break; } default: { return string.Empty; } } } else if (length == 2) { switch (combustivel[1]) { case '0': { if (combustivel == "10") { break; } return string.Empty; } case '1': { if (combustivel == "11") { return "7"; } return string.Empty; } case '2': { if (combustivel == "12") { break; } return string.Empty; } default: { return string.Empty; } } } else { return string.Empty; } return "5"; } return string.Empty; } } }