Ejemplo n.º 1
0
        public void SetAdditionalData(UpdateMaintenanceDataInputModel model)
        {
            StringBuilder updateQuery = new StringBuilder();

            updateQuery.Append($"update {model.TableName} t ");
            updateQuery.Append($" set t.monthsdriven = {model.MonthsDriven} , t.kilometersdriven = {model.KilometersDriven} ");

            int recordId = GetLastRecordId(model.TableName, model.MotorcycleId);

            updateQuery.Append($" where t.id = {recordId} ");

            CommandExecuter.CommandExecuter.ExecuteNonQuery(updateQuery.ToString());
        }
Ejemplo n.º 2
0
        private void AddKilometersAndMonthsDriven(string maintenanceType, int motorcycleId, string changeDate, int kilometersOnChange)
        {
            if (maintenanceService.IsNotLast(maintenanceType, motorcycleId))
            {
                CalculationDataModel calcDataModel = maintenanceService.GetCalculationDataModel(maintenanceType, motorcycleId);

                int monthsDriven     = maintenanceService.CalculateMonthsDriven(DateTime.ParseExact(changeDate, "dd.MM.yyyy", CultureInfo.InvariantCulture), calcDataModel.ChangeDate);
                int kilometersDriven = maintenanceService.CalculateKilometersDriven(kilometersOnChange, calcDataModel.KilometersOnChange);

                UpdateMaintenanceDataInputModel updateModel = new UpdateMaintenanceDataInputModel
                {
                    KilometersDriven = kilometersDriven,
                    MonthsDriven     = monthsDriven,
                    TableName        = maintenanceType,
                    MotorcycleId     = motorcycleId,
                };

                maintenanceService.SetAdditionalData(updateModel);
            }
        }