private void Editar(DTOFrete frete)
        {
            var freteModel = FreteModel.Transform(frete);
            var sql        = ActiveRecord.Update(freteModel);

            using (var contexto = new Contexto())
            {
                contexto.ExecutaComando(sql);
            }
        }
 public void Salvar(DTOFrete frete)
 {
     if (frete.Id > 0)
     {
         Editar(frete);
     }
     else
     {
         Incluir(frete);
     }
 }
        public static FreteModel Transform(DTOFrete frete)
        {
            var modeloModel = new FreteModel
            {
                Id    = frete.Id.ToString(CultureInfo.InvariantCulture),
                Uf    = frete.Uf.ToString(CultureInfo.InvariantCulture),
                Frota = frete.Frota.ToString(CultureInfo.InvariantCulture),
                Valor = frete.Valor.ToString(CultureInfo.InvariantCulture)
            };

            return(modeloModel);
        }
        private void Incluir(DTOFrete frete)
        {
            var freteModel = FreteModel.Transform(frete);
            var sql        = freteModel.QueryInsert();

            using (var contexto = new Contexto())
            {
                var result = contexto.ExecutaComandoComRetorno(sql);
                result.Read();
                frete.Id = Convert.ToInt32(result["LASTID"]);
            }
        }
 public HttpResponseMessage Put(DTOFrete frete)
 {
     try
     {
         _freteServico.Salvar(frete);
         return(Request.CreateResponse(HttpStatusCode.OK, frete));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
 public void Salvar(DTOFrete frete)
 {
     _freteRepositorio.Salvar(frete);
 }