private void CreateNewBattery(string maintenanceType) { if (!IsMoney(PriceTextBox.Text)) { MessageBox.Show("Price must be a number", GlobalConstants.MessageBoxTopInfo); return; } if (!IsKilometers(KilometersOnChangeTextBox.Text)) { MessageBox.Show("Kilometers must be a number", GlobalConstants.MessageBoxTopInfo); return; } CreateBatteryInputModel model = new CreateBatteryInputModel { Make = MakeTextBox.Text, MotorcycleId = GlobalVariables.CurrentBikeId, KilometersOnChange = int.Parse(KilometersOnChangeTextBox.Text), ChangeDate = ChangeDateDatePicker.Value.ToString("dd.MM.yyyy"), Price = double.Parse(PriceTextBox.Text), }; batteryService.CreateBattery(model); AddKilometersAndMonthsDriven(maintenanceType, model.MotorcycleId, model.ChangeDate, model.KilometersOnChange); }
/// <summary> /// Create new oil /// </summary> /// <param name="model"></param> public void CreateBattery(CreateBatteryInputModel model) { StringBuilder createBatteryQuery = new StringBuilder(); createBatteryQuery.Append($"execute procedure insertintobattry({model.Price},'{model.Make}','{model.ChangeDate}',{model.MotorcycleId},{model.KilometersOnChange});"); CommandExecuter.CommandExecuter.ExecuteNonQuery(createBatteryQuery.ToString()); }
public IActionResult Create() { var viewModel = new CreateBatteryInputModel(); viewModel.CategoriesItems = this.categoriesService.GetAllAsKeyValuePairs(); viewModel.BrandsItems = this.brandsService.GetAllAsKeyValuepairs(); viewModel.CapacityItems = this.capacityService.GetAllAsKeyValuepairs(); viewModel.AmperageItems = this.amperageService.GetAllAsKeyValuepairs(); viewModel.TechnologyItems = this.technologyService.GetAllAsKeyValuepairs(); return(this.View(viewModel)); }
public async Task CreateAsync(CreateBatteryInputModel input) { var battery = new Battery(); battery.BrandId = input.BrandId; battery.CapacityId = input.CapacityId; battery.AmperageId = input.AmperageId; battery.CategoryId = input.CategoryId; battery.TechnologyId = input.TechnologyId; battery.BatteryDescription = input.BatteryDescription; await this.batteryRepository.AddAsync(battery); await this.batteryRepository.SaveChangesAsync(); }
public async Task <IActionResult> Create(CreateBatteryInputModel input) { if (!this.ModelState.IsValid) { input.CategoriesItems = this.categoriesService.GetAllAsKeyValuePairs(); input.BrandsItems = this.brandsService.GetAllAsKeyValuepairs(); input.CapacityItems = this.capacityService.GetAllAsKeyValuepairs(); input.AmperageItems = this.amperageService.GetAllAsKeyValuepairs(); input.TechnologyItems = this.technologyService.GetAllAsKeyValuepairs(); return(this.View(input)); } // return this.Json(input); await this.batteryService.CreateAsync(input); // TODO create Battery using service method // TODO redirect to Battery info-page return(this.Redirect("/")); }