public IHttpActionResult Save(FuelDetail oFuelDetail)
        {
            ///oFuelDetail.CreatedAt = DateTime.UtcNow;
            oFuelDetail.ModifiedAt = oFuelDetail.CreatedAt;
            var ofuelDetail = rep.Save(oFuelDetail);

            return(Ok(ofuelDetail));
        }
 public FuelDetail[] GetListFuelDetailByUserId(FuelDetail oFuelDetail)
 {
     using (var cnn = SimpleDbConnection())
     {
         cnn.Open();
         FuelDetail[] result = cnn.Query <FuelDetail>(
             @"SELECT *
             FROM FuelDetail WHERE UserId=@UserId ", oFuelDetail).ToArray();
         return(result);
     }
 }
 public FuelDetail GetFuelDetailById(FuelDetail oFuelDetail)
 {
     using (var cnn = SimpleDbConnection())
     {
         cnn.Open();
         FuelDetail result = cnn.Query <FuelDetail>(
             @"SELECT *
             FROM FuelDetail WHERE Id=@Id ", oFuelDetail).FirstOrDefault();
         return(result);
     }
 }
        public FuelDetail Save(FuelDetail oFuelDetails)
        {
            using (var cnn = SimpleDbConnection())
            {
                cnn.Open();
                oFuelDetails.Id = cnn.Query <int>(
                    @"INSERT INTO FuelDetail
                    ( UserId, MeterReading, TotalPrice, AddedFuel, Note, CreatedAt, ModifiedAt  ) VALUES 
                    ( @UserId, @MeterReading, @TotalPrice, @AddedFuel, @Note, @CreatedAt, @ModifiedAt );
                    select last_insert_rowid()", oFuelDetails).First();

                oFuelDetails = GetFuelDetailById(oFuelDetails);
                return(oFuelDetails);
            }
        }